Simple functions of jquery

Source: Internet
Author: User

1. Basic syntax for jquery functions:

$ (document). Ready (function () {

code block;

})

2.window.onload () and $ (document) the distinction between ready ():

1) window.onload () It is time to wait for all content in the Web page to be loaded (including pictures) to execute, $ (document). Ready () executes after all DOM structures are drawn in the Web page

2) Number of writes:

Window.onload () cannot execute multiple simultaneously: for example

Window.onload () =function () {

Alert ("First");

}

Window.onload () =function () {

Alert ("Second");

}

The results only output "Second".

$ (document). Ready () can write multiple executions: for example

$ (document). Ready (function ()

{

Alert ("Hello first!");

});

$ (document). Ready (function ()

{

Alert ("Hello second!");

});

Two will output, and sequentially output;

3) Simplified notation:

$ (document). Ready (function ()

{

code block;

});

Simplified:

$ (function () {

code block;

});

Simple functions of jquery

Related Article

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.