Given a select
<select id="Myselect">
<option value="-1">Please Select<option>
<option value="1">Selection 1<option>
<option value="2">Selection 2<option>
</select>
What the best way to determine if there is an option of value X in the select with JQuery?
You can do this using a selector and
.length, like this:Or as a function:
If it’s not numbers and you may have
'in there for example (screwing the selector), you can use.filter(), like this: