I have some Select elements being populated with updated options on an interval. I'd like to access the new options programmatically to check whether a select contains an option with a certain value.
I've tried this snippet:
var exists = false;
$('#select-box option').each(function(){
if (this.value == 'bar') {
exists = true;
return false;
}
});
(From Check if value is in select list with JQuery)
But the options that this is exposing are only the placeholder options defined in the html. How can I access the options that were created by pushing new html to the element?
The selects are just defined as
<select id=select-box><option>Placeholder</option></select>.
To update them, I'm passing several conjoined
<option>text</option>
tags to $("#select-box").html().