Jituu
Jituu

Reputation: 151

Remove a class when another class is present in another div

I am working on this site.

Here there are 2 menus. One at the left and another at the right top.

When the Menu of the left button is open and one clicks on the right top menu, it goes under the menu.

So I want to close the left menu when the right one is open.

I have added the below script to make it work:

jQuery('.all-cases-link b').click(function(){
    if(jQuery('.all-cases').hasClass('active')){
        jQuery("body").find('.site-navigation').removeClass('active');
    }
});

But it is not working for some reason. If I add the code to the console, it is working, but not when I put to the head or foot area.

Can someone please point me in the correct direction?

Thank you.

Upvotes: 0

Views: 309

Answers (1)

Momin IqbalAhmed
Momin IqbalAhmed

Reputation: 970

Try to use code snippet. Left menu open and close based on #hamburger id.

jQuery('.all-cases-link b').click(function(){ 
//jQuery('.all-cases-link b').on('click', function(){ //Use this if above line does not work
        if(jQuery('#hamburger').hasClass('is-opened-navi')){
            jQuery('#hamburger').trigger('click');
        }
});

Upvotes: 1

Related Questions