Home > Web Front-end > JS Tutorial > body text

Introduction to various methods and differences between jquery and js initialization loading_jquery

WBOY
Release: 2016-05-16 16:53:43
Original
1282 people have browsed it

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

js: wait for the page to be fully loaded before executing the initial loading.

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

The first (more commonly used):

Copy code The code is as follows:

$.function(){
alert("First method");
});

Second type:
Copy code The code is as follows:

$(document).ready(function(){
alert("Second method");
});

Third method:
Copy code The code is as follows:

jQuery(function($){
alert(" Three methods");
});

2. Method of js initialization loading
The first method:
Copy the code The code is as follows:

window.onload=function(){
alert("Initial load");
};

Second type:
(winOnload this method name is customized)
Copy code The code is as follows:

function winOnload() {
alert("Initial load");
};
winOnload();

Note: Due to jquery Using the $ symbol conflicts with some components such as dwr. In order to solve this problem, you can use
to copy the code . The code is as follows:

var ace=jQuery.noConflict();
Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!