I am using jquery to populate dropdownlist, the codes are like below:
var myOptions = {
val1 : 'text1',
val2 : 'text2',
val3 : ''
};
$.each(myOptions, function(val, text) {
$('#mySelect').append( $('<option></option>').val(val).html(text)
);
});
now I have populate 3 items in my dropdown, and now I want to set my dropdownlist selected value with ”, just like:
$("#mySelect option contain('')").attr(selected,true).
Actually, this will get all 3 items so that it will not set ” as selected value, is there any way that i can do this?
1 Answer