Set dropdown Selected text using jquery
This is a method that works based on the text of the option, not the index. Just tested.
Or, if there are similar values :
var theText = "GOOGLE";
$("#HowYouKnow option:contains(" + theText + ")").attr('selected', 'selected');
Or, if there are similar values :
$("#HowYouKnow option").each(function() {
if($(this).text() == theText) {
$(this).attr('selected', 'selected');
}
});
Comments