petko_stankoski
petko_stankoski

Reputation: 10713

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.

Upvotes: 0

Views: 280

Answers (2)

Julien Fouilhé
Julien Fouilhé

Reputation: 2658

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

Upvotes: 2

Stefan Neubert
Stefan Neubert

Reputation: 1054

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

Upvotes: 1

Related Questions