jquery objects go to DOM, Dom to jquery

Source: Internet
Author: User
jquery objects converted to DOM objects
jquery provides two ways to convert a jquery object into a DOM object, which is [index] and get (index). Some people might find it strange, how to use subscript, yes, the jquery object is an array object.
The following code shows a way to convert a jquery object into a DOM object and then use the DOM object
Copy the code code as follows:

var $cr =$ ("#cr"); jquery Object
var cr = $CR [0]; Dom objects can also be written as Var cr= $cr. Get (0);
alert (cr.checked); Detects if the checkbox is selected

Dom objects converted into jquery objects
For a DOM object, you simply wrap the DOM object with $ () and you can get a jquery object by $ (DOM object);
Copy the code code as follows:

var Cr=document.getelementbyid ("Cr"); Dom Object
var $CR = $ (CR); Convert to jquery Object

The method of jquery can be used arbitrarily after the conversion.

jquery objects go to DOM, Dom to jquery

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.