The conversion of jquery objects and JS objects

Source: Internet
Author: User

jquery object can only use Jqury method, cannot use JS method, on the contrary, JS object can only use JS method, if the JS object using the jquery method, then the browser will error.

However, at some specific times, we need to use the JS method for jquery objects, which will use the transformation between the two objects.

The jquery object is converted to a JS object:

1 var person = $ ("div"); // This is a Jquer object 2 3 var per1 = person[0]; // at this point the Per1 is a JS object 4 var per2 = person.get (0); // at this time the Per2 is also a JS object

JS objects into jquery objects:

var fruit = getElementById ("wrap"); // This is a JS object var fruit1 = $ ("fruit"); // at this point the fruit1 is a jquery object

Use $ to convert any JS object into a jquery object.

The conversion of jquery objects and JS objects

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.