Why/when do I have to tap twice to trigger click on iOS

前端 未结 11 2292
一生所求
一生所求 2020-12-13 17:49

Ok I feel like I\'m crazy...

I\'m looking at Mobile Safari on iOs 6.0. I can\'t seem to establish any rhyme or reason as to when tapping on an element will trigger

11条回答
  •  误落风尘
    2020-12-13 18:23

    you can use ontouchstart instead of onclick event on element and call the function focus() on this element if it is input :

    document.getElementById('plain-div').addEventListener('touchstart', function() {
       //write body of your function here
        alert(“hi”);
      // if input needs double tap 
      this.focus();
    
    });
    

提交回复
热议问题