简体   繁体   中英

Jquery on ipad doesn't work

This code:

$('#x').hide();
$('#y').hide();
alert($('#y').is(":visible"));
alert($('#x').is(":visible"));

when on ipad, shows two alerts which say true. How is this possible? On Chrome they show false, as they are supposed to.

You should use the callback parameter :

$('#x').hide(0, function() {
    alert($('#y').is(":visible"));
});

The function will be executed only when the animation is finished. Though, this is supposed to be done without any animation...

I think jQuery does not wait for animations to be finished before the next code is interpreted. Maybe the IPad is faster interpreting than hiding and therefore both elements are still visible.

You can check this by using window.setTimeout

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