Reputation: 155
$('.select option:selected[innerHTML="5"]')
My goal here is to select an option which is currently selected and which's innerHTML matches exactly a string (example : "5")
Here's a fiddle : http://jsfiddle.net/kxkzU/4/
This : $('.select option:selected:contains("5")')
does not work since then value 0.375 would match.
Upvotes: 0
Views: 2389
Reputation: 95054
Use filter:
$('.select option:selected').filter(function(){
return this.innerHTML == 5;
}).html("good");
Also, your fiddle had .select
as the className instead of just select
.
Upvotes: 5