Jquey notes-conversion between DOM objects and jquery objects

Source: Internet
Author: User

1. Conversion between DOM objects and jquery objects

<HTML>  "  Content-Type  " Content = "  Text/html; charset = UTF-8  " > <SCRIPT type = "  Text/JavaScript  " Src = "  Jquery-1.3.1.js  " > </SCRIPT>  " Text  " Id = "  Test  " Value = "  Test  " > <Input type = "  Button  " Value = "  Submit  " Onclick = "  Testing () " > <SCRIPT type = "  Text/JavaScript  " > //  Pure js method      VaR Obj1 = Document. getelementbyid ( "  Test  "  ); Function Testing (){  VaR Obj1 = Document. getelementbyid ( "  Test  " ); Window. Alert (obj1.value );}  //  For a jquery object, specify that the name of a jquery object starts with $.      VaR $ Obj2 = $ ( "  # Test  "  ); Window. Alert ($ obj2.val ());  //  Output Test  //  Dom-> jquery object  /* $ (Document). Ready (function () {var $ obj3 = $ (obj1); // obj3 is the jquery Object window. Alert ($ obj3.val ());});  */      //  Jquery-> DOM object  //  There are two methods. 1.  $ (Document). Ready (function (){  //  The first method is to treat an object as a set in jquery development.  //  VaR obj4 = $ obj2 [0];  //  Obj4 is a DOM object.  // Method 2          VaR Obj4 = $ obj2. Get ( 0  ); Window. Alert (obj4.value );  //  Output Test  }); </SCRIPT> </body> 

 

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.