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 #cart
it 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
Post a Comment