How to bind both Mousedown and Touchstart, but not respond to both? Android, JQuery

后端 未结 9 835
无人及你
无人及你 2020-12-04 14:24

Working on a website that is also viewable on mobile and need to bind an action on both touchstart and mousedown.

Looks like this

 $(\"#roll\").bind         


        
9条回答
  •  -上瘾入骨i
    2020-12-04 14:57

    Fixed using this code

    var mobile   = /Android|webOS|iPhone|iPad|iPod|BlackBerry/i.test(navigator.userAgent); 
    var start = mobile ? "touchstart" : "mousedown";
    $("#roll").bind(start, function(event){
    

提交回复
热议问题