Would onClick event work on touch on touch-screen devices?

前端 未结 2 1698
天命终不由人
天命终不由人 2020-12-04 01:28

I\'ve used onclick events in my website. But when I open it in google chromes\' developer mode\'s mobile view, nothing happens on touch on the elements which wo

相关标签:
2条回答
  • 2020-12-04 02:11

    onclick may not work on touch devices, I had this issue and the event ontouchstart sorts it. if you use ontouchstart and onclick watch that you don't trigger the event twice.

    this is another post related onClick not working on mobile (touch)

    0 讨论(0)
  • 2020-12-04 02:22

    onclick works fine on touchscreens; I've used it several times and have never had any problem.

    You could consider using onmousedown instead of onclick. Or use jQuery to detect taps.

    0 讨论(0)
提交回复
热议问题