简体   繁体   中英

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

$('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.

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.

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...

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() ?

.live() is still available in jquery 1.4.3.

.on() for jquery 1.11

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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