Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jQuery - hide option element by value

Trying to hide an option element from a list. I have tried several methods however, cannot seems to work. I need to call select by name as I cannot add ID or class.

$('select[name*="boxes"] option[value="box6"]').hide();

here the fiddle: http://jsfiddle.net/q2nb08t6/

any suggestions?

like image 579
SNos Avatar asked Jul 04 '26 18:07

SNos


1 Answers

If you can go with removing it, this seems to work in all browsers:

$('select[name*="boxes"] option[value="box6"]').remove();

Tested in FF, Chrome, Safari, IE and Opera.

Demo Fiddle

like image 181
Ted Avatar answered Jul 07 '26 07:07

Ted



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!