troubleshooting Question

Problem using alert in events in jQuery Mobile on iPhone/iPad

Avatar of Stefan Lennerbrant
Stefan LennerbrantFlag for Sweden asked on
25 Comments1 Solution3374 ViewsLast Modified:
The checkbox in the jQueryMobile html below uses an onClick event to display an alert() popup.
Clicking the checkbox puts a mark in it, and displays the alert. All ok, so far.

However, the event handler is also fired when one thereafter "leaves" the checkbox (clicking outside it, to loose focus)
Thus, the alert is displayed then as well. This is wrong.
Also, the checkbox is un-marked. This is really really wrong! :-)

I get this behaviour ONLY on iPhone/iPad (I'm testing with Safari). It works ok on Android and "computer" browsers (well, actually I haven't tried using Safari on other plattforms maybe this is a Safari issue?)

Does anybody know that happens here?

<!DOCTYPE html>
<html xmlns="">
<link rel=stylesheet href="" type="text/css">
<script src=""></script>
<script src=""></script>
function doclick()
  alert('A click');
<div data-role=page id=m_c2main>
<div data-role=content>
  <label><input name=CHECK type=checkbox value=1 onClick="doclick()">A checkbox</label>
Stefan Lennerbrant

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 25 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 25 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros