One possible option is to use nth-child
pseudo-selector like this:
$('select::nth-child(2)').attr('selected', true);
Or, if the select is properly done, like this:
<select>
<option value="1">1</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
</select>
You can select via the value
attribute:
$('select>option[value=4]').attr('selected', true);
Since you will surely want to have more of the links, it's handy to define a function:
JS
function showOptWithValue(which) {
$('select>option[value=' + which + ']').attr('selected', true);
}
Now, to bind this function to your link, you can either use onclick
:
HTML
<a href="#" onClick="showOptWithValue(3); return false;">The Link</a>
Or assign the click handler with pure jquery:
HTML
<a href="#">The Link</a>
JS
$('a').on('click', function(){
showOptWithValue(3);
return false;
});
Here is the JSFiddle with some working example: http://jsfiddle.net/FY3tz/1/