I've got a loop building an option set that I fill up an empty node with using jQuery.
i.e;
var optList = function(){
var list;
for(i=0;i<5;i++){
list += '<option>'+i+'</option';
}
return optList;
}
$('#mySelect').html(optList());
My question is, given my output string from optList is there a way of having adding "selected" to a predetermined value? like: <option selected>4</option> using my string? I'm asking because I build my optList BEFORE I am aware of what that predetermined value will be.
$('#mySelect').val(someValue). Setting value of<select>itself is same as settingselectedon the option tag