JQuery send event? how

How can I send an event to my window? For example, in my code, I have:

$("#info").click(function(){
// do stuff
});

I need to call this function for the first time, without clicking on #info, in how // to do things.

+5
source share
2 answers

You can use the method .trigger():

$('#info').trigger('click');

or simply:

$('#info').click();

which would be the same.

+11
source

The best method would be to create a function that does the desired material and then $(document).ready(myFunc);and $("#info").click(myFunc);.

+11
source

All Articles