Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
55
rated 0 times [  60] [ 5]  / answers: 1 / hits: 15347  / 13 Years ago, thu, september 8, 2011, 12:00:00

I have the folowing selector



    var likeComperssionOption = $('select[id*=ComparisionType]').eq(0)
.find(option:contains('LIKE'));


this checks for an option which contains the word 'like' right?



How do i find an option which is exactly with the word 'like'?



Somthing like this:



     var likeComperssionOption = $('select[id*=ComparisionType]').eq(0)
.find(option:equals('LIKE'));

More From » jquery

 Answers
41

Just select all the options from the select and filter them by text() value:



var likeComperssionOption = $('select[id*=ComparisionType]:first option').filter(function() { return $(this).text() == LIKE });

[#90208] Tuesday, September 6, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
dequant

Total Points: 88
Total Questions: 99
Total Answers: 95

Location: Ukraine
Member since Sun, Dec 13, 2020
4 Years ago
dequant questions
;