Use jQuery to set select menu value

Hello all,

I have a select menu with option values from 1 - 10. At the moment the option with value=“3” is selected:

<option value="3" selected="selected">3</option>

How do I use jQuery to make value=“5” selected? I.e.,

<option value="5" selected="selected">5</option>

Been fiddling around with val() but no luck so far. Perhaps one of you has a better idea? Thank you in advance

$("#myselect").val('5'); doesn’t work?

@vion9929,

turns out that I didn’t have to use val() but .attr(‘selected’, ‘selected’).

Thanks!

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.