An in-depth analysis of jquery object $.html_jquery

Source: Internet
Author: User

$ object

When it comes to jquery, the most obvious sign, no doubt, is, in fact, a shorthand for jquery. Objects that use the $ () wrapper are jquery objects

Corresponding to the JQuery object is the DOM object, which is actually a DOM element node object

If you write document directly, you are referring to the DOM element object of document

Document.onclick = function () {
alert (' Dom ');
}

if () included () included, such as (document), the shorthand form of jquery (document), the jquery object

<script src= "Jquery-3.1.0.js" ></script> 
<script>
console.log (jquery (document));//[ Document]
Console.log ($ (document))//[document]
Console.log (document)//#document
</script>

[Note that the]jquery object cannot use the DOM object's method, nor can the DOM object use the JQuery object method

<script src= "Jquery-3.1.0.js" ></script> 
<script>
//No reaction
$ (document). onclick = function () {
alert (0);
};
Uncaught TypeError:document.click is not a function
Document.click (function () {
alert (1);
});
</script>

Transformation

"1" Dom goto jquery Object

For a jquery object, you can get a jquery object by wrapping the DOM object with $ ()

"2" jquery turn DOM Object

jquery is a class array object that can be obtained by [index] or get (index) to the corresponding DOM object

Console.log (document = = $ (document) [0]);//true
console.log (document = = $ (document). Get (0));//true

Coexistence

If the jquery object and the DOM object point to the same object and bind different functions, the functions are executed sequentially

Pop 0 First, then eject 1
document.onclick = function () {
alert (0);
}
$ (document). Click (function () {
alert (1);
});

The above is a small set to introduce the JQuery object $.html, I hope to help you, if you have any questions please give me a message, small series will promptly reply to everyone. Here also thank you very much for the cloud Habitat Community website support!

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.