Possible Duplicate:
What is the difference between these jQuery ready functions?

$(function(){
    // ... do stuff
});

VS

$(document).ready(function() {
    // ... do stuff
});

I saw the first one in some old code and I assume the two are similar? Is there a benefit to one over the other?

有帮助吗?

解决方案

According to the jQuery Documentation those are equivalent

其他提示

they are the same exact thing. i started using the 1st method now as it's more shorthand

They are the same, except the first version is just shorthand.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top