Using JQuery, how can I check to see if a dropdown menu contains a value? By value, I don’t mean the text displayed as a menu item. I mean the ID (val) of the item. I have a list of items already in the dropdown menu, and I want to add more. Before I do that, I want to make sure I do not duplicate any key-value pairs.
Share
Something like this will do what you want. (JSFiddle)
html
js
If you use an older jQuery version than 1.7 use
.bindinstead of.on.