javascript - Jquery. toggleclass to not toggle on click on child -


i'm using :

$("#cart").click(function(e){     $('#cart').load('index.php?route=module/cart #cart > *');     var e=window.event||e;     $("#cart").toggleclass("active");     e.stoppropagation();     $(document).click(function(e){        $("#cart").removeclass("active");         $('#cart').live('mouseleave', function() {         });       }); }); 

now problem whenever click on child of #cartit toggles class, don't want. how can make toggle when click on #cart , not on child ?

to check if event handler has been called because of event bubbling, compare this event.target within event handler:

$('#cart').on('click', function(event){   if(this === event.target){     // $('#cart') clicked    } else {    // event has bubbled descendant of $('#cart')   } }); 

Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -