Question

$(document).ready(function() { 
    $('.MobileMenu').click(function() {
        $(".MobileMenu ul.le_menu_level_1").stop().slideToggle(200);
        return false;
    });
});

I want to prevent the return false form happening on the child elements. How would I go about making this happen?

Was it helpful?

Solution

You can check that the clicked element is the same as the one bound in the event handler, and not a click that bubbled up from a child :

$(document).ready(function() { 
    $('.MobileMenu').click(function(e) {
        $(".MobileMenu ul.le_menu_level_1").stop().slideToggle(200);
        if (e.target === this) return false;
    });
});
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top