gpt4 book ai didi

javascript - jQuery 对话框上的 onclick 事件不适用于 IOS

转载 作者:行者123 更新时间:2023-11-29 00:45:54 26 4
gpt4 key购买 nike

我正在使用 IOS 设备并开发应用程序。我在对话框中遇到 onclick 事件的问题。我在对话框中有一个文本框,需要使用 onclick 事件调用一个函数。但它不适用于 IOS(Ipad/iPhone)。有人可以检查一下并建议我吗?下面是在 IOS 中不起作用的简单代码。我已经尝试了 ontouchstart 事件,它工作正常但是 onclick 有什么问题?

-对话框中的代码

<input type="text" onclick="hello();">
<script>
function hello()
{
alert(2222);
}
</script>

最佳答案

Ther is an issue with IOS not registering click/touch events bound to elements added after DOM LOADS.

IN you code to the below changes and it should work.

<input type="text" onclick="hello();" style="cursor:pointer">

The above line will fix your code.

Also you can refer the below link and know in depth as to why the IOS does not register click/touch events.

http://www.quirksmode.org/blog/archives/2010/09/click_event_del.html

Hope this gives you a better understanding. Appreciate your comments.

关于javascript - jQuery 对话框上的 onclick 事件不适用于 IOS,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38590509/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com