When I click anything on the page, other than .card
I want my function to fire. It works perfectly, however, if I have a <h2>hello</h2>
inside my .card
and I click on that, it also fires.
How do I get my jQuery to not fire if all/any elements inside .card
are clicked, including .card
?
Here is my code:
$('body').click(function(evt){
if(!$(evt.target).is('.card')) {
$('.card').removeClass('active');
$('.offer2').addClass('active');
}
});