[英]Click events not working on Apple devices
So I have a web page that whenever you click into an image it show up in a bigger form.所以我有一个 web 页面,只要你点击一张图片,它就会以更大的形式显示。
The code is simple (obviating the rest of the code)代码简单(省去了代码的rest)
open_image.addEventListener("click", () => open_image());
<div id="click-me"> <img src="img_test.jpg"> </div> <div id="bigger-img" style="display: none"> <img src="img_test.jpg"> </div>
What open_image() function does is simply setting display block to the hidden image open_image() function 所做的只是将显示块设置为隐藏图像
This works without problems in PC and android devices, but for apple mobiles devices such as iPad or iPhone the click event seems not to be listened or is like its ignoring it.这在 PC 和 android 设备上没有问题,但对于苹果手机设备,如 iPad 或 iPhone,点击事件似乎没有被监听或者就像它忽略它一样。
I've searched for solutions and seems like in CSS the property cursor: pointer should work, but not for me, after setting this property to the body keeps ignoring the click event.我已经搜索了解决方案,似乎在 CSS 中,属性 cursor: pointer 应该可以工作,但对我来说不是,在将此属性设置为正文后一直忽略点击事件。
Any ideas for these apple devices?这些苹果设备有什么想法吗?
use "touchend" in addition to the click event https://developer.mozilla.org/en-US/docs/Web/API/Element/touchend_event使用“touchend”除了点击事件https://developer.mozilla.org/en-US/docs/Web/API/Element/touchend_event
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.