I have a group of rows selected and I am now trying to determine whether or not they contain a specific class.
I have tried it with hasClass without success as well as with find:
var group = $('table').find('[data-group="group1"]');
//this doesn't work, it always enters in the condition
if(group.find('.active')){
alert("Founded?");
group.addClass('green');
}
http://jsfiddle.net/kAHyA/1/
I have also tried it with if(group.find('.active').length) but still not getting the correct result:
http://jsfiddle.net/kAHyA/3/
You can do this with hasClass method http://api.jquery.com/hasClass/
if(group.hasClass('active')){
...
}
If you tried this :
if(group.hasClass('.active')){
...
}
It certainly won't work, note the difference with the "."
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With