Kirn
Kirn

Reputation: 524

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 $();.

Upvotes: 1

Views: 75

Answers (2)

Lily Ballard
Lily Ballard

Reputation: 185671

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.

Upvotes: 0

deceze
deceze

Reputation: 522016

jQuery(function () { }), or $(function () { }), is shorthand for jQuery(document).ready(function () { }). See http://api.jquery.com/jQuery/#jQuery3.

Upvotes: 6

Related Questions