Shortest way of firing a function on ready with jquery -


this such trivial question, have function...

galleryajax(); 

and fire on doc ready. writing this...

jquery(document).ready(function($) {    galleryajax(); }); 

it seems little long hand , wondering if there shorted way of writing this.

thanks
josh

you can directly pass function jquery:

$(galleryajax); 

from .ready documentation:

all 3 of following syntaxes equivalent:

$(document).ready(handler) $().ready(handler) (this not recommended) $(handler) 

of course if want execute more functions on dom ready, makes sense pass anonymous function:

$(function() {     galleryajax();     // other functions called here }); 

Comments

Popular posts from this blog

assembly - 8086 TASM: Illegal Indexing Mode -

javascript - addthis share facebook and google+ url -

Java, LWJGL, OpenGL 1.1, decoding BufferedImage to Bytebuffer and binding to OpenGL across classes -