This question already has an answer here:
This function works perfectly on IE, Firefox and Chrome but when on the iPhone, it will only work when clicking on a <img>
. Clicking on the page (anywhere but on a img) wont fire the event.
$(document).ready(function () {
$(document).click(function (e) {
fire(e);
});
});
function fire(e) { alert('hi'); }
The HTML part is extremely basic and shouldnt be a problem.
Any ideas?
try this, applies only to iPhone and iPod so you're not making everything turn blue on chrome or firefox mobile;
basically, on iOS, things aren't "clickable" by default -- they're "touchable" (pfffff) so you make them "clickable" by giving them a pointer cursor. makes total sense, right??
Adding in the following code works.
The problem is iPhones dont raise click events. They raise "touch" events. Thanks very much apple. Why couldn't they just keep it standard like everyone else? Anyway thanks Nico for the tip.
Credit to: http://ross.posterous.com/2008/08/19/iphone-touch-events-in-javascript