How can I hide select options with JavaScript? (Cross browser)

Unfortunately, you can’t hide option elements in all browsers.

In the past when I have needed to do this, I have set their disabled attribute, like so…

$('option').prop('disabled', true);

I’ve then used the hiding where it is supported in browsers using this piece of CSS…

select option[disabled] {
    display: none;
}

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)