Introduction of jquery and js initialization loading methods and differences

  • 2020-03-30 02:31:40
  • OfStack

The difference between jquery and js initialization load page:
Jquery: wait for the page to load the data, and some elements of the page (excluding pictures and videos),

Js: the initialization load is performed when the page is fully loaded.

1. There are three ways to initialize the loading of jQuery page. The script will be executed when the page is loaded.

The first (more common) :
 
$.function(){ 
alert(" The first way "); 
}); 

The second:
 
$(document).ready(function(){ 
alert(" The second way "); 
}); 

The third:
 
jQuery(function($){ 
alert(" Third way "); 
}); 

2. Js initialization method of loading
The first:
 
window.onload=function(){ 
alert(" Initial loading "); 
}; 

The second:
(winOnload method name custom)
 
function winOnload() { 
alert(" Initial loading "); 
}; 
winOnload(); 

Note: since jquery USES the $sign, it conflicts with some components such as DWR. To solve this problem, you can use it
 
var ace=jQuery.noConflict(); 

Related articles: