Just Thinking

Fourth Woods Blog

Determine if a value is an option in a select element with jQuery

Posted on 9 November, 2012  in JavaScript, Programming

To determine if an html select box contains a given value as an option, in jQuery you can try to select the option and see if it exists:

if($("#id option[value='someval']").length != 0)
{
   // it exists!
}

That’s it! Have fun!

Recommended reading:

, , , , ,

0 thoughts on“Determine if a value is an option in a select element with jQuery

Leave a Reply

Your email address will not be published. Required fields are marked *