This question already has an answer here:
I would like to select an option in a drop down menu by its' text. When I run the code,:
var theText = "Large";
$("#size option:contains(" + theText + ")").attr('selected', 'selected');
it selects XLarge instead of Large. Is there any way to make it select Large? JSFiddle: http://jsfiddle.net/r8wuP/2/
You can use .filter() to find an exact match, :contains-selector returns partial matches also
Demo: Fiddle
Try this:
http://jsfiddle.net/r8wuP/3/
Since you're using 1.4 this would work:
However later jQuery versions might need the filter method.