Reputation: 11
Thank you in advance for anyone who helps on this one.
We have a drop down with a blank option in the first .
<select id="Flags">
<option></option>
<option value="Corporate">Corporate.png</option>
<option value="Store2">Store2.png</option>
</select>
If the first blank option is selected, how can I remove it and select "Store2"?
If $('#Flags option[value=""]')
Then .remove();
and $('#Flags').val ("Store2")
Thank you very much in advance for any help.
Upvotes: 0
Views: 129
Reputation: 337560
Try this:
$("#Flags").change(function() {
if (!$(this).val())
$(this).val("Store2");
});
It would be better to just have Store2
as the default with not blank option, as you may confuse your users if they choose the blank item, yet see 'Store2.png' selected.
Upvotes: 3