How would I select my dropdown list item by text rather than value?
I want to select a dropdown item by text with jQuery.
There is a filter function on jQuery that you can use to get elements with something more specific
$("select option").filter(function() {
return $(this).text() == "text_to_select";
});
This is going to return all options with the "text_to_select" in the text.
i think this will do the trick for you...
$("#selectId").find("option:contains('text')").each(function(){
if( $(this).text() == 'Text that should be matched' ) {
$(this).attr("selected","selected");
}
});