This should be so simple, but it's not working for me. I want to say:
If this doesn't have the class "current" AND if the body class does not equal "home", then do this....
Here is what I'm trying (among other things) to no avail. Only the first conditional works.
$(".nav1 > ul > li").mouseleave(function() {
if ( (!$(this).hasClass("current")) || (!$(body).hasClass("home")) ){
$(this).find(".nav-overlay").show();
}
});
What am I doing wrong? Thank you!
UPDATE FOR CLARITY:
I only want to show ".nav-overlay" when the following conditions are true:
- You are not on the homepage (body class="home") AND
- The ".nav1 > ul > li" class does not equal "current"
If
body
is not a variable, access it as a HTML tag: add quotes. Also,AND
is&&
instead of||
(that meansOR
):If
body
is a jQuery object you can do directly... && !$body.hashClass(...)
.Try
$("body")
and&&
:Or this way , it is shorter: