Jquery - if page loaded

后端 未结 9 1687
[愿得一人]
[愿得一人] 2021-02-05 15:57

Is there any trick how to start a function in javascript, which starts when the page is completely loaded?

相关标签:
9条回答
  • 2021-02-05 16:35

    You are looking for the window load event.

    In jQuery you attach the load event as follows:

    $(document).ready(function() {
    
      $(window).load(function() {
    
      }
    
    }
    

    Note that you need to place this inside a document ready for some browsers, IE8 OTTOMH.

    0 讨论(0)
  • 2021-02-05 16:37

    Check this: http://api.jquery.com/ready/

     jQuery(document).ready(function($) {
     // Code using $ as usual goes here.
     });
    
    0 讨论(0)
  • 2021-02-05 16:41
    $( window ).bind( 'load', function()
    {
        //your code in here
    } );
    
    0 讨论(0)
提交回复
热议问题