I'm unable trigger a click on the body tag using jQuery, I'm using this...
$('body').click();
even this fails
$('body').trigger('click');
Any ideas?!
I'm unable trigger a click on the body tag using jQuery, I'm using this...
$('body').click();
even this fails
$('body').trigger('click');
Any ideas?!
You should have something like this:
$('body').click(function() {
// do something here
});
The callback function will be called when the user clicks somewhere on the web page. You can trigger the callback programmatically with:
$('body').trigger('click');
I've used the following code a few times and it works sweet:
$("body").click(function(e){
//you can then check what has been clicked
var target = $(e.target);
if (target.is("#popup")) {
}
}
interestingly.. when I replaced
$("body").trigger("click")
with
jQuery("body").trigger("click")
IT WORKED!!!
if all things were said didn't work, go back to basics and test if this is working:
<html>
<head>
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$('body').click(function() {
// do something here like:
alert('hey! The body click is working!!!')
});
</script>
</body>
</html>
then tell me if its working or not.