Eliminate 300ms delay on click events in mobile Safari

后端 未结 10 2179
北恋
北恋 2020-11-28 18:34

I\'ve read that mobile Safari has a 300ms delay on click events from the time the link/button is clicked to the time the event fires. The reason for the delay is to wait to

10条回答
  •  生来不讨喜
    2020-11-28 18:49

    This plugin -FastClick developed by Financial Times does it perfectly for you!

    Make sure though to add event.stopPropagation(); and/or event.preventDefault(); directly after the click function, otherwise it might run twice as it did for me, i.e.:

    $("#buttonId").on('click',function(event){
        event.stopPropagation(); event.preventDefault();
       //do your magic
    
    });
    

提交回复
热议问题