Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

trigger body click with jQuery

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

$('body').click();

Even this fails:

$('body').trigger('click');
like image 824
ruturaj Avatar asked May 28 '09 08:05

ruturaj


1 Answers

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');
like image 166
kgiannakakis Avatar answered Nov 15 '22 16:11

kgiannakakis