lundi 22 juin 2015

Stop Prevent Default in else clause

Hello I have a mobile nav where some items have a subnav so I have set a preventDefault to stop these doing there normal actions and open the sub menu but some don't have a submenu ad now these don't work as normal.

Any help would be great here is my code. Also this is a mobile only problem.

 $('.touch .mobile-list > li > a').on('click', function(e){
            e.preventDefault();
            if($(this).parents('li').hasClass('visible-submenu')) {
                $(this).parents('li').removeClass('visible-submenu');

            } else {
                 $('.mobile-list li.visible-submenu').removeClass('visible-submenu');
                 $(this).parents('li').addClass('visible-submenu');
            }

        });

Aucun commentaire:

Enregistrer un commentaire