Saturday, March 3, 2012

curiosity of Jquery "$(document).ready()" or "$()" what's different?

Just wondered. what's the difference and what it is.

I found out that is same either anyway.

$(document).ready(function() {
  // Handler for .ready() called.
});

Which is equivalent to calling:

$(function() {
 // Handler for .ready() called.
});

so, I will use shorter one.

Applied to the Hello Jquery!.

$(function() {
    $("a").click(function() {
    alert("Hello Jquery!");
    });
});

refer from : http://api.jquery.com/ready/

No comments:

Post a Comment