I know that you can check to see if an id (or other selector) has a certain class:
$('#mydiv').hasClass('bar')
But can you check to see if a class also has another class? Like:
$('.myclass').hasClass('bar')
Just wondering?
This is trivial to test. See it working on jsFiddle (a great online tool for web developers).
<div id="mydiv" class="myclass bar">
</div>
jQuery:
alert($('.myclass').hasClass('bar'))
you can try like this
if($('.myclass').find('bar').length > 0)
//Do you code
hope this helps you
.myclassthis will return true as long as one of them has.bar