I have a select
field with some options in it. Now I need to select one of those options
with jQuery. But how can I do that when I only know the value
of the option
that must be selected?
I have the following HTML:
<div class="id_100">
<select>
<option value="val1">Val 1</option>
<option value="val2">Val 2</option>
<option value="val3">Val 3</option>
</select>
</div>
I need to select the option with value val2
. How can this be done?
Here's a demo page: http://jsfiddle.net/9Stxb/
Is old post but here is one simple function what act like jQuery plugin.
You just simple can do something like this:
Reson why use this is because you change selected satemant into DOM what is crossbrowser supported and also will trigger change to you can catch it.
Is basicaly human action simulation.
a simple answer is, at html
on jquery, call below function by button or whatever
it simple and 100% works, coz its taken from my work... :) hope its help..