This works in desktop safari, but in the iOS version no alert pops up. Is it possible to bind to the 'html' element in iOS? I want to close a drop-down menu whenever the user clicks somewhere else on the page.
$('html').bind("click", function(){alert("clicked!")})
EDIT
Posting this as html since jsfiddle embeds in an iframe, which apparently gets rid of my issue. Opening this page on desktop safari works fine, but in the iOS simulator it doesn't show anything on clicking.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<script type="text/javascript">
$(document).ready(function(){
$('html, body').bind("click", function(){alert("html or body")})
$(document).bind("click", function(){alert("document")})
});
</script>
<body>
</body>
</html>
EDIT 2
This also doesn't work for me in the iOS simulator or on my iPhone. I do get the alerts if I put the delegate() in my app and click on a link.
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<body>
</body>
<script type="text/javascript">
$(document).delegate('html, body', "click", function(){alert("html or body")});
</script>
</html>
EDIT 3
This works!
<html>
<head>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js" type="text/javascript"></script>
<body>
<div id="stuff">applesauce</div>
<div>other stuff</div>
</body>
<script type="text/javascript">
$(':not[#stuff]').on( "click", function(){alert("not stuff")});
</script>
</html>