Set An Option With A Specific Value From Select Box
Here we consider how to select an option with a specific value from Select Box.
Lets start with one example here.
Suppose we have a Select Box with ID selectID as shown here.
There are three options avaialable on this Select Box.
Now we would like to set an option with value google by using jQuery.
In jQuery, we can set an option with a value as shown here.
$('#selectID option[value=google]').attr('selected', 'selected');
$('#selectID option[value=google]').prop('selected', 'selected');
Here we find the option in the select box with a value google.
And then it attribute selected will be set as selected.
By this way, we can set an option with a specific value from Select Box.