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

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:

Tags: , , , , ,

Friday, November 9th, 2012 JavaScript, Programming

Leave a Reply


Comments are moderated due to spammers. Your comments will not appear until I review and approve them. If you left a question I will answer as best I can so be sure to check back.