Using Self Calling Anonymous Functions and $(document).ready

后端 未结 3 1445
-上瘾入骨i
-上瘾入骨i 2021-02-04 17:50

I just recently learned about self calling anonymous functions. Some snippets of code that I came across used the self calling function along with the $(document).ready. It se

3条回答
  •  时光取名叫无心
    2021-02-04 18:33

    You wouldn't want to use both together, is there something you're doing that requires you to?

    In the jquery api documentation here, http://api.jquery.com/ready/, you can see these examples:

    The .ready() method is typically used with an anonymous function:

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

    });

    Which is equivalent to calling:

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

    });

    But I'm not sure if this answers your question because I don't see where you actually ask one. Hope this helps just the same!

提交回复
热议问题