How to bind 'touchstart' and 'click' events but not respond to both?

前端 未结 30 3039
抹茶落季
抹茶落季 2020-11-22 14:08

I\'m working on a mobile web site that has to work on a variety of devices. The one\'s giving me a headache at the moment are BlackBerry.

We need to support both key

30条回答
  •  囚心锁ツ
    2020-11-22 14:35

    This is the fix that I "create" and it take out the GhostClick and implements the FastClick. Try on your own and let us know if it worked for you.

    $(document).on('touchstart click', '.myBtn', function(event){
            if(event.handled === false) return
            event.stopPropagation();
            event.preventDefault();
            event.handled = true;
    
            // Do your magic here
    
    });
    

提交回复
热议问题