how can i dispatch an event on my window ready? For example in my code i've got:
开发者_JS百科$("#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.
You could use the .trigger()
method:
$('#info').trigger('click');
or simply:
$('#info').click();
which would be the same.
A better way might be to make a function that does the required stuff, then do $(document).ready(myFunc);
and $("#info").click(myFunc);
.
精彩评论