JS jquery Page Load Initialization method

Source: Internet
Author: User

JS jquery Page Load Initialization method

A. js page load Initialization method

 // 1. Write the initialization method inside the body  .<Bodyonload= ' init () '></Body><Scripttype= "Text/javascript">    function init (){         //Initialize content    }</Script>
// 2.window.onload=function () {} <Scripttype= "Text/javascript">window.onload=function(){         //Initialize content    }</Script> 
//3. Write initialization method, page order execution to initialize method when initialized <  type= "Text/javascript">    function  init () {            Initialize content     };      </ Script >

Two. jquery page load Initialization method

 //1.$.function () {}  <  script  type  = "text/ JavaScript " >   $.  function   () { //  initialize content  });  </ script  >  
 //2.$ (document). Ready (function () {})  <  script  type  = "Text/javascript"  >   $ (document). Ready ( function   () { //  initialize content  });  </ script  >  
//3.jQuery (function ($) {}) <  type= "Text/javascript">    jQuery (function($) {           // Initialize content     });   </ Script >

Three. The difference between jquery and JS initialization loading pages
jquery: Wait for the page to finish loading data, as well as part of the page elements (excluding pictures, videos),
JS: It is the full loading of the page before performing the initialization load.

JS jquery Page Load Initialization method

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.