Reputation: 231
how can i dispatch an event on my window ready? For example in my code i've got:
$("#info").click(function(){
// do stuff
});
I need to call this function the first time without have a click on #info, in the way // do stuff.
Upvotes: 7
Views: 35663
Reputation: 70859
A better way might be to make a function that does the required stuff, then do $(document).ready(myFunc);
and $("#info").click(myFunc);
.
Upvotes: 11
Reputation: 1038930
You could use the .trigger()
method:
$('#info').trigger('click');
or simply:
$('#info').click();
which would be the same.
Upvotes: 13