$(document).ready(function(){
if (!$('body').hasClass('home') || !$('ul#main-menu li.wwd').hasClass('active')){
$("ul#sub-menu").css('display','none');
$(".main-content").css('margin-top','13px');
$("ul#sub-menu").mouseover(function() {
$("ul#sub-menu").show();
$(".main-content").css('margin-top','62px');
}).mouseout(function() {
$("ul#sub-menu").hide();
$(".main-content").css('margin-top','13px');
});
$("li.wwd").mouseover(function() {
$("ul#sub-menu").show();
$(".main-content").css('margin-top','62px');
}).mouseout(function() {
$("ul#sub-menu").hide();
$(".main-content").css('margin-top','13px');
});
}
if ($('ul#main-menu li.wwd').is('.active')){
$(".main-content").css('margin-top','62px');
}
})
I need to run this jQuery on all pages besides the home page(that works fine) but also not on pages where li.wwd
has class active
. I thought this would work with an OR operation but it does not. Thanks for any help in advance.
To evaluate the !(not)
condition for both places you need to use &&
instead of ||
, just like
if (!$('body').hasClass('home') && !$('ul#main-menu li.wwd').hasClass('active'))
{
// code goes here
}