Skip to main content
Stack Overflow
  1. About
  2. For Teams

Timeline for answer to What does $(function() {} ); do? by Russ Clarke

Current License: CC BY-SA 3.0

Post Revisions

10 events
when toggle format what by license comment
Mar 2, 2017 at 3:47 comment added thdoan "Experienced developers sometimes use the shorthand $() for $( document ).ready(). If you are writing code that people who aren't experienced with jQuery may see, it's best to use the long form." - learn.jquery.com
Oct 4, 2011 at 1:54 vote accept jwchang
Oct 4, 2011 at 1:52 comment added jwchang @vidas (function() {})(); to define a function and to use it right away right?
Oct 4, 2011 at 1:51 comment added jwchang my JS file has about 450 lines... though mine has somewhat non-sense behavior.. I'll take account this answer. Thank you :)
Oct 4, 2011 at 1:50 comment added Russ Clarke Please feel free to add that to my answer Šime, it'll probably be more clearer with a properly formatted sample...
Oct 4, 2011 at 1:48 comment added Šime Vidas @JeongWooChang Do it like so (function () { ... })();. You have to add () to invoke your function.
Oct 4, 2011 at 1:45 comment added Russ Clarke Good question! I believe it should just work, as jQuery knows you're in the right place, but it's certainly extraneous; if you're inside .ready() you can just call your function as normal. If it's not working, then post a sample, or even better - try and make a fiddle as jsfiddle.net.
Oct 4, 2011 at 1:43 comment added jwchang the function does not work without $(function() though it is already in $(document)ready().
Oct 4, 2011 at 1:43 comment added jwchang what if $(function() { }); is already in $(document).ready() ?
Oct 4, 2011 at 1:37 history answered Russ Clarke CC BY-SA 3.0

AltStyle によって変換されたページ (->オリジナル) /