jquery Re-learning (1)

Source: Internet
Author: User

One: The jquery object and JS Dom object convert each other

HTML code

1 <ul>2     <binclass= "SXF"name= "DD">First</Li>3     <Liclass= "SXF"name= "DD">Second</Li>4     <Liclass= "SXF"name= "DD">Third</Li>5     <Liclass= "SXF"name= "DD">Fourth</Li>6 </ul>7 <inputtype= "button"value= "Test"onclick= "Test ();">
View Code

JS Code

1 functionTest () {2     //jquery object (class array)3     var$li =$ (". Sxf");4Alert ($li. length);//45     //Jquery-->dom Object (subscript starting from 0)6     varLi= $li [0];7alert (li.innerhtml);//First8     //Jquery-->dom Object (subscript starting from 0)9     varLid= $li. Get (1);Tenalert (lid.innerhtml);//Second One      A     //DOM Objects (arrays) -     varDli=document.getelementsbyname ("DD"); -alert (dli.length);//4 the     //DOM--->jquery object (subscript starting from 0) -     var$ld =$ (dli[2]); -Alert ($ld. HTML ());//Third -     //DOM--->jquery object (the first element in the array is converted to a jquery object by default) +     var$ads =$ (DLI); -Alert ($ads. HTML ());//First +      A}
View Code

two : The difference between the Readay event of jquery and the Load event of window

$ (document). Readay (function () {//All execution code});

$ (function () {//All execution code});

Window.onload=function () {//All execution code};

----> Page load Rendering order
(1) parsing the HTML structure
(2) loading external scripts and style sheet files
(3) parsing and executing script code
(4) Constructing the HTML DOM model
(5) loading external files such as pictures
(6) Page load complete
the Reday event of the--->juqery is activated when the HTML DOM model is constructed (4)
--->load event will be activated when external files such as (5) loading pictures are completed.
--->reday event can be written in more than one page. are able to execute
--->load event can only be written in one page. If you write more than one, perform the last one, the front of the invalidation.

jquery Re-learning (1)

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.