onClick事件是否会触摸触摸屏设备? [英] Would onClick event work on touch on touch-screen devices?
问题描述
我在我的网站上使用了 onclick
事件。但是,当我在google chromes的开发人员模式的移动视图中打开它时,触摸用鼠标点击的元素时没有任何反应。所以我的问题是:
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 work on click with mouse. So my question is:
我还必须添加 ontouch
事件以及 onclick 事件或onClick事件可以在所有触摸屏设备上触摸?
Do I have to also add ontouch
events along with onclick
events, or onClick event work on touch on all touch-screen devices?
PS:您可以在这里看到我所有的代码: https://github.com/SycoScientistRecords/sycoscientistrecords.github.io/
P.S: You can see all of my codes here: https://github.com/SycoScientistRecords/sycoscientistrecords.github.io/
或在直播网站: http://sycoscientistrecords.github.io
没有我在真实手机上测试过网站。
And no I haven't tested the website on real phone.
推荐答案
onclick
works fine on touchscreens; I've used it several times and have never had any problem.
您可以考虑使用 onmousedown
,而不是的onclick
。或者使用 jQuery 检测水龙头。
You could consider using onmousedown
instead of onclick
. Or use jQuery to detect taps.
这篇关于onClick事件是否会触摸触摸屏设备?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!