Reputation: 11247
I have a HTML Select
element with various options. Each option has an attribute called label
.
How can I set option as selected by this attribute value?
Upvotes: 0
Views: 34
Reputation: 1075587
You can look up the option
using an attribute equals selector, then set its selected
property to true
using prop
.
$('option[label="the value here"]').prop("selected", true);
Upvotes: 3