In JQuery, what does $ (document) mean? jquerydocument

Source: Internet
Author: User

In JQuery, what does $ (document) mean? jquerydocument

First of all, I will explain that jQuery has a handy small function used to quickly load javascript as DOM, that is, ready... It is executed before page loading is complete.

Why not use window. onload (), because when the window. onload function is executed, it indicates that everything has been loaded, including images and banners. You need to know that the download speed of a large image is relatively slow. Therefore, you must wait until the download of the large image is complete before you can see the window. it takes a long wait time for the code executed by onload (), which is not what we want.

However, $ (document). ready (fn): binds a function to be executed when the DOM is loaded and can be queried and manipulated.

This is the most important function in the event module, because it can greatly improve the response speed of web applications.

Simply put, this method is purely an alternative to registering an event with the window. load event. By using this method, you can call the function you bind immediately when the DOM is ready to read and manipulate. $ (document ). ready (function () {// your code });

(Optional) (document, obtains the entire webpage Document Object (the website's Yu weijing Doc ument ),

$ (Document). ready means that when the document object is ready. The above code indicates checking the Document Object until it can be operated. the onload () function is much faster, because the code can be executed as long as the file object is loaded, without waiting for the image download on the page to complete.) --- this is what we want.


In jquery, $ () $ represents

"$" --> Indicates the identifier to let the browser know that this is jquery
"$ (Function () {})" --> is equivalent to $ (document ). ready (function () {Specific Method body}); tells the browser to execute this method after the DOM structure is complete. Unlike onload, onload is after the content is loaded.

What is the dollar sign "$" in Jquery, and why is it necessary to use "$ "?

In the jQuery file, $ = jQuery is defined;
$ ("# Id") is the same as jQuery ("# id.
Only $ has been used in other js frameworks and may be repeated.

It is not clear why it is used in this way. But many frameworks are like this. This is also true for prototype. js frameworks.

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.