简体   繁体   English

按钮单击javascript无法在iPad / iPhone Safari中运行

[英]button click javascript not running on iPad/iPhone safari

Hello I was reading up on this problem and people had mentioned that to get click to run on safari and chome you needed to have the code set up like so 您好,我正在阅读有关此问题的信息,人们已经提到要让点击在Safari和chome上运行,您需要像这样设置代码

$('input[type=submit]#btnIsAddress').bind('click', function (event) {

    alert("this is code");
    selectAddress(event);
    event.preventDefault();
    return false;
});

This code works on all browsers on a desktop and will work on Chrome, Dolphin and Mercury on an iPad but it will not work on safari on an iPad (go figure the most used one...) Instead it will treat the button as if its just text, it doesn't even try to run someone or give me the little click animation when pressed. 此代码适用于台式机上的所有浏览器,并且适用于iPad上的Chrome,Dolphin和Mercury,但不适用于iPad上的野生动物园(请参阅最常用的一个...),而是将按钮当作它只是文本,它甚至不试图运行某人或在按下时给我一点点击动画。

However I have noticed that if I let the iPad go to sleep mode while on the page then turn the iPad back on the button will work with no problem. 但是,我已经注意到,如果在页面上让iPad进入睡眠模式,然后重新打开iPad按钮就可以了。

Has anyone else run into this sort of problem before? 有人遇到过这种问题吗? I'm guessing its something to do with my javascript but it seems like pretty simple script... 我猜想它与我的javascript有关,但似乎很简单的脚本...

We don't see the entire context. 我们看不到整个上下文。 If you're button is dynamically added to the DOM then did you try using .live() instead of .bind() ? 如果您将按钮动态添加到DOM,那么您是否尝试使用.live()而不是.bind()?

.live() is still available in jquery 1.4.3. .live()在jquery 1.4.3中仍然可用。

.on() for jquery 1.11 .on()for jquery 1.11

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM