Black Horse DAY16 jquery Primer

Source: Internet
Author: User

Jquery:

1.jQueryobject is throughJQueryPackagingDOMObject that is generated after the object。jquery objects are unique to jquery. If an object is a jquery object, it can use the method in jquery: $ ("#test"). html ();

For example:

$ ("#test"). html () means: Gets The HTML inside the element with ID test Code. where html () is the method in jQuery

This code is equivalent to using the DOM Implementation code:

document.getElementById ("test"). InnerHTML;

Although jquery objects are created after wrapping a DOM object, jquery cannot use any of the DOM object's methods, nor does the DOM object use the methods in jquery. Random use will errorConventions:If you are getting a JQuery object, precede the variable with $. ? var$variable = JQuery Object? varvariable = DOM Object 2. If you use jquery :In head: <script language= "JavaScript" src= ". /js/jquery-1.4.2.js "&GT;&LT;/SCRIPT&GT;SRC The directory structure where the jquery framework is importedConvert a 3.dom object to a jquery object ... jquery into a DOM object ...

(1). Dom object converted to jquery object

<script language= "JavaScript" >   //dom into jquery object  $ (DOM object) var Obj=document.getelementbyid (" Username ");//alert (Obj.value)   ; var $obj =$ (obj);   Alert ($obj. Val ());  </script>
(2). jquery objects are converted to DOM objects ...

Method One: The jquery object is an array object that can be obtained by means of the [index] ObjectWay Two: jquery itself provides, through the. Get (Index) method, to get the corresponding DOM object
<script language= "JavaScript" >   //jquery objects into DOM objects   //(1) The JQuery object is an array object that can be obtained by means of [index] to the corresponding DOM object   var $username =$ ("#username");   var username= $username [0];   alert (username.value);   (2) jquery itself provides, through the. Get (Index) method, to get the corresponding Dom object     var $username =$ ("#username");   var username= $username. Get (0);   alert (username.value);  </script>


Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.

Black Horse DAY16 jquery Primer

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.