Is there any way to call function 'before document ready' in Jquery?

后端 未结 3 1208
滥情空心
滥情空心 2020-12-14 16:01

I want to call function before document get ready, so is there any method in Jquery to do this?

相关标签:
3条回答
  • 2020-12-14 16:07

    If you are using .hide() or display: none; - the hiding of the divs will be displayed.

    try:

    visibility: hidden;
    

    it worked for me after trying many other ways.

    0 讨论(0)
  • 2020-12-14 16:16

    If you simply call a function in the head tag it will execute immediately, before the DOM is even parsed (that's the 'problem' that ready solves).

    <!doctype html>
    <html>
        <head>
            <script>alert(1)</script>
        </head>
        <body>
        </body>
    </html>
    
    0 讨论(0)
  • 2020-12-14 16:18

    Just call your function before the document ready statement.

    <script>
       thisWillFireImmediately();
    
       $(function() {
          thisWillFireOnDocumentReady();
       });
    </script>
    
    0 讨论(0)
提交回复
热议问题