How many times can I have jQuery's document ready function declared on a page?

后端 未结 3 1859
迷失自我
迷失自我 2021-02-05 08:42

How many times is it permitted to have the jQuery document ready function declared on a page, i.e.:

$(function () { ... });

or

         


        
3条回答
  •  隐瞒了意图╮
    2021-02-05 09:00

    As many times as you like. They fire in order of declaration.

    $(document).ready() will fire when the document is ready (when it's all loaded by the browser). The other one will fire as soon as that part of the script executes.

提交回复
热议问题