Home » Javascript » Jquery hasClass Code not Working

Jquery hasClass Code not Working

Posted by: admin August 19, 2018 Leave a comment

Questions:

I’m trying to make it so when any other slide is active besides the home page slide it hides the menu: ocw2018.orangecoastwebsites.com

I was using this code:

$(document).ready(function () {
    if ($('.about-us, .services, .portfolio, ocw-whole-testimonials, .ocw-blog, .contact-us').hasClass('uncode-scroll-active')) {
        $('#menu-main-menu').hide();
    } else {
        $('#menu-main-menu').show();
    }
});

In the console, it works fine, but I’m not sure why it’s not working on the live site.

Edit:

Basically I want what this code is able to do but with a hasClass instead of hover

$(window).on('hover', function(){
    if(
    $('.about-us').hasClass('uncode-scroll-active') ||
    $('.services').hasClass('uncode-scroll-active') || 
    $('.portfolio').hasClass('active') || 
    $('.ocw-whole-testimonials').hasClass('uncode-scroll-active') || 
    $('.ocw-blog').hasClass('uncode-scroll-active') || 
    $('.contact-us').hasClass('uncode-scroll-active')) {
        $('#menu-main-menu').hide();
    } else {
        $('#menu-main-menu').show();
    }
});

It is live on the URL I provide above, so you can see when you scroll to the next page, and move your mouse, the menu disappears. It’s my workaround until I figure out how to make it hidden when a class is active.

Answers: