Eliminate 300ms delay on click events in mobile Safari

后端 未结 10 2178
北恋
北恋 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:50

    In jQuery you can bind "touchend" event, witch trigger code inmediatly after tap (is like a keydown in keyboard). Tested on current Chrome and Firefox tablet versions. Don't forget "click" also, for your touch screen laptops and desktop devices.

    jQuery('.yourElements').bind('click touchend',function(event){
    
        event.stopPropagation();
        event.preventDefault();
    
    	// everything else
    });

提交回复
热议问题