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?!
interestingly.. when I replaced
with
IT WORKED!!!
if all things were said didn't work, go back to basics and test if this is working:
then tell me if its working or not.
I've used the following code a few times and it works sweet:
As mentioned by Seeker, the problem could have been that you setup the
click()
function too soon. From your code snippet, we cannot know where you placed the script and whether it gets run at the right time.An important point is to run such scripts after the document is ready. This is done by placing the
click()
initialization within that other function as in:This is usually the best method, especially if you include your JavaScript code in your
<head>
tag. If you include it at the very bottom of the page, then theready()
function is less important, but it may still be useful.You should have something like this:
The callback function will be called when the user clicks somewhere on the web page. You can trigger the callback programmatically with: