Matthieu Riegler
Matthieu Riegler

Reputation: 55836

JQuery's on() don't work on iOS

I have a Javascript that looks like that

$(document).on("click", "#nearLines", function () {
    $("#loadingAnim").show();
    $("#indexChoices").slideToggle("slow", "swing", function () {
        getNearLines();
    })
});

It works well on desktop browsers but on iOS, when tapping on the div whose ID is nearLines nothing happens. Any idea why ?

PS: I tried it with jquery.min 2.0.3 and 1.9.1.

Upvotes: 1

Views: 847

Answers (1)

Dominic Green
Dominic Green

Reputation: 10258

This is a strange answer but jquery click doesn't play well with ios if your not binding to a anchor tag. It cant tell that your button is a click event so will not do anything.

Try adding this to your css

#nearLines{cursor:pointer;}

This basically tells ios that your div is a link.

Try the example below on your ipone to see what I mean

http://jsfiddle.net/VncKc/2/

Upvotes: 2

Related Questions