Reputation: 11635
I am trying this
$("ul.nav-tabs a:contains('profile')").parent().addClass("active")
It don't work if i have Profile in there.
Profile
Is there any way to make that case insensitive
case insensitive
Upvotes: 0
Views: 87
Reputation: 148150
If you are looking for text of a then use filter()
a
$("ul.nav-tabs a").filter(function() { if($(this).text().toLowerCase() == "profile") return $(this).parent(); }).addClass("active");
Upvotes: 1
Reputation: 145408
You should use filter() instead of :contains selector:
filter()
:contains
$("ul.nav-tabs a").filter(function() { return /profile/i.test($.text(this)); }).parent().addClass("active");