ontouchstart在iPad中不可用

ontouchstart not available in iPad?

本文关键字:iPad ontouchstart      更新时间:2023-09-26

我想在iPad上隐藏一个基于项目触摸的元素。以下链接显示-https://developer.apple.com/library/archive/documentation/AppleApplications/Reference/SafariHTMLRef/Articles/Attributes.html,Safari支持ontouchstart属性,但它不起作用。在这种情况下我们该怎么办?我不会使用任何JavaScript。我只需要在html中实现它。

我的代码:

<div class="myclass" id="overlay" ontouchstart="hideElement()" onclick="hideElement()" onmousedown="hideElement()"></div>

无法直接在html元素上添加ontouchstart。因为它只支持Apple扩展。你可以在这里看到:

支持级别

苹果扩展。

您可以使用Jquery或不同的Apple扩展来实现这一点。您可以在此处找到有关Apple扩展的更多详细信息:https://developer.apple.com/app-extensions/