Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

jquery : $(document).ready only accept anonymous handler?

Is it possible to have a defined function as a handler to jQuery's $(document).ready() instead of anonymous function ?

I've done several experiments but to no avail. One of them is here : http://pastebin.com/XHKPc879.

like image 339
Dino Avatar asked Feb 22 '26 23:02

Dino


1 Answers

Yes, it is possible:

function pancakes() { /* Do interesting things */ }
$(document).ready(pancakes);

The problem with your pastebin:

$(document).ready(test());

is the you're calling the test function when you say test(), just drop the parentheses and you're good.

like image 81
mu is too short Avatar answered Feb 25 '26 12:02

mu is too short



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!