Jquery contains with class
I am using jQuery: contains a selector for filtering through link tags. The following code works great.
$('a:contains("string")').each(function(i){
//do some stuff
});
I would only like to run this function if the anchor tags are inside a specific class, I've tried the following but it doesn't work:
$('.my_class a:contains("string")').each(function(i){
//do some stuff
});
+2
a source to share
4 answers
None of these will work. You have brackets and wrong quotes all over the store.
$('a:contains(string)').each(function(i){
//do some stuff
});
and then
$('.my_class a:contains(string)').each(function(i){
//do some stuff
});
Which is working now: http://www.jsfiddle.net/muzQQ/
+2
a source to share