I’ve delcared a click callback on a div that I would like ignored if a user clicks on a link inside that div. The function looks like this:
$(".section").click(function(){
if ($(this).hasClass("solid")) {
$(this).removeClass("solid");
$(this).hover(fadeFunction, darkenFunction);
$(this).fadeTo(150, inactiveOpacity);
}
else {
$(this).addClass("solid");
$(this).unbind("mouseenter");
$(this).unbind("mouseleave");
$(this).fadeTo(25, inactiveOpacity);
$(this).fadeTo(150, activeOpacity);
}
});
I’ve tried wrapping the if/else up in a if(!$(this).is("a)) { but there is no change in behavior. Can somebody point out what I’m misunderstanding or doing wrong?
Sorry if this is an easy question, I’m a JQuery/css beginner.
You can check if the event target is an anchor, like this: