I'm using jQuery :contains selector to filter through some link tags. The following code works great.
$('a:contains("string")').each(function(i){
//do some stuff
});
I'd like only run this function if the anchor tags are inside a specific class, I've tried the following but it does not appear to work:
$('.my_class a:contains开发者_开发问答("string")').each(function(i){
//do some stuff
});
To select by class name, put a dot at the start:
$('.my_class a:contains("string")')
Neither of those will work. You've got brackets and mis matching quotes all over the shop.
$('a:contains(string)').each(function(i){
//do some stuff
});
and then
$('.my_class a:contains(string)').each(function(i){
//do some stuff
});
Which now works: http://www.jsfiddle.net/muzQQ/
Try this, with a dot at the start of the class name:
$('.my_class a:contains('string').each(function(i){
//do some stuff
});
<div class="GridCell">Click to review.</div>
if you need to get the above using jQuery, use
$('div.GridCell:contains(Click to review.)')
精彩评论