JQuery Learning Process Notes

Source: Internet
Author: User

The 1:$ symbol indicates that jQuery can be equivalent to $=jquery

For example: $ (); = = JQuery ();

$ (function () {alert ("What is represented by")}); = = jquery (function () {alert ("the $ symbol means jquery")});

2:dom Objects and jquery objects (jquery objects cannot invoke DOM objects, nor can the DOM invoke jquery objects)

A) When you convert a jquery object to a DOM object, you only need to invoke the method or property of the jquery object

For example:

$(

function () {

var $li = $ ("li");//jquery Method $ ("Li") Gets the JQuery object collection Li data

var li = $li [0]; Get a DOM object from the index of the jquery object, at which point the conversion is complete

You can now invoke the Li's Dom method or property.

});

b) The DOM object is converted to a JQuery object, and a direct call to the $ () function translates

For example:

$(

function () {

var li = document.getelementbytagnames ("Li"); Get all Li Collections

var $li = $ (li[0]); Call the $ () function directly into the jquery object, which we

You can also convert the entire Li array directly with the $ () function, that is: var $li = $ (LI);

Alert ($li. HTML ());

}

);

a jquery object cannot invoke a DOM object, nor can the DOM invoke a jquery object

For example:

<script type= "Text/javascript" >
$ (function () {
var $li = $ ("li");
var li = $li. Get (0);
  $li. Append ($ ("<li> new Item </li>"));
alert (li.innerhtml);
});
</script>

Print effect

    • The one Li
    • New Item
    • The LI
    • New Item
    • The thred Li
    • New Item

If we replace the red Code for $li.get (0). Append ($ ("<li>new item</li>")); we don't get what we want.

As a result, the object has been converted to a DOM object after a Get (index) conversion of the JQuery object, append

is a jquery object, so the result is not correct, another: var li = $ (li[0]);

Note: differentiate $ (LI); $li; $ ("Li") different meanings $ (LI) conversion, $li set jquery object, $ ("Li") gets the Li object.

The difference between the 3:jquery's ready and the DOM's OnLoad method

The effect is consistent when no external files need to be loaded, and ready is better than onload when there are external files loaded (synchronous)

Explanation: The ready for jquery is executed after the DOM is drawn, and the onload is executed after the page is fully loaded, knowing that this knowledge requires

Learn about the order in which browsers load Web pages. Do not repeat (when there is an external file loaded with jquery ready (), no two can);

Dom Object onload can only be executed once in a Web page, while jquery's ready event can be executed any time ($ (function () {jquery code}))

The 4:$ ("id") effect is equivalent to document.getElementById ("id") but the function is not equivalent to the former which has the ability to convert to jquery objects, which can be in $ ("id")

After calling the JQuery method, the latter cannot.

To be continued ****************************//

JQuery Learning Process Notes

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.