Jquery – trigger body click with jQuery

clickeventsjquerytriggers

I'm unable to trigger a click on the body tag using jQuery using this:

$('body').click();

Even this fails:

$('body').trigger('click');

Best Solution

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');