stopPropagation() with tap event

后端 未结 5 1870
[愿得一人]
[愿得一人] 2021-02-15 02:12

I\'m using hammer.js and it appears that I event.stopPropagation() doesn\'t work with tap event.

If I click on the child, the associated event is triggered

5条回答
  •  旧时难觅i
    2021-02-15 02:43

    If you can't get this to work.. just call another method on the tap after verifying the needful (arguments.callee is where I would start in such a case) , this would have the added benefits of letting other users hook the button also...

    function myFn(a) { if(a) $(this).css('background', 'red'); else $(this).css('background', 'blue');}

    $('#parent').hammer().bind('tap', function(e) {
       //Check arguments.callee or other data in event and call myFn
    });​​​​​​​​
    
    $('#children').hammer().bind('tap', function(e) {
      //Same here
    });
    

提交回复
热议问题