Find if device is touch screen then apply touch event instead of click event

前端 未结 4 1692
日久生厌
日久生厌 2020-12-22 01:52

I am creating a phonegap application, but as I came to know that it takes 300MS to trigger click event instead of touchevent.

I don\'t want to apply both event. Is t

4条回答
  •  执笔经年
    2020-12-22 02:07

    You can try:

    var clickEvent = ((document.ontouchstart!==null)?'click':'touchstart');
    $("#mylink").on(clickEvent, myClickHandler);
    

提交回复
热议问题