A variety of methods and different introduction to the initialization of jquery and JS _jquery

Source: Internet
Author: User
jquery and JS initialize the difference in loading pages:
jquery: Waiting for the page to finish loading data, and part of the page elements (excluding pictures, videos),

JS: Is the page full load complete before performing initialization loading.

1, jQuery page load initialization method There are 3 kinds, the page will be loaded when the script executes,

The first (more commonly used):
Copy Code code as follows:

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

The second type:
Copy Code code as follows:

$ (document). Ready (function () {
Alert ("second method");
});

The third type:
Copy Code code as follows:

JQuery (function ($) {
Alert ("Third method");
});

2, JS initialization of the loading method
First type:
Copy Code code as follows:

Window.onload=function () {
Alert ("Initialize load");
};

The second type:
(Winonload this method name customization)
Copy Code code as follows:

function Winonload () {
Alert ("Initialize load");
};
Winonload ();

Note: Because jquery uses the $ symbol, and some components such as dwr have conflicts, in order to solve this problem, you can use the
Copy Code code as follows:

var ace=jquery.noconflict ();

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.