You can use the prop method.
var id = 'sel02'; $('#mySelect option').filter(function(){ return this.id === id }).prop('selected', true);
or
$('#' + id).prop('selected', true);
Or, if you want to select an option based on this index, you can use the eq method:
$('#mySelect option').eq(1).prop('selected', true);
undefined
source share