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

后端 未结 3 1901
迷失自我
迷失自我 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:01

    As many as you need.

    The document ready function adds to what is essentially an event queue - the functions in these declarations will all be executed, either at the document.ready event, or immediately if that event has already fired, in order of declaration.

提交回复
热议问题