I am wondering why the $(function () {} is getting executed all the time. function test(0 is not. what's the difference between those two?
jQuery's extreme shorthand tends to trick the eye sometimes.
Look closely at the construct: A function named $ gets called, with the function as an argument. This is not equal to defining a function for later use like function test() { .... }
$ is jQuery's "document ready" shortcut. The function passed to it will get executed once the document is loaded.
this is a short form for document ready.
$("document").ready(function(){});
so it will execute every time document loads
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With