What does this mean $();?
$();
I think it's from jQuery. I'm used to using $(document).ready(function(){});
from jQuery but someone used $(function(){});
and I'm confused how you开发者_如何学编程 could have an anonymous function within the $();
.
jQuery(function () { })
, or $(function () { })
, is shorthand for jQuery(document).ready(function () { })
. See http://api.jquery.com/jQuery/#jQuery3.
According to this page, wrapping a callback in $()
executes the callback when the page is ready (similar to using $(document).ready(callback)
, or (I believe) immediately if the document is already ready.
精彩评论