Conversion between a jquery object and a JS native DOM object

Source: Internet
Author: User

Jqueryis thatJSan extension library, tool library, provides a lot of quick and easy way, so willJSobject is converted toJQueryobject, the object can be manipulated more easily. ButJQueryobjects are not omnipotent, there are someJSobjects can be,JQueryobject is not provided, so it needs to be converted back toJSobject in order to operate. Another scenario might be that you use some third-party libraries, and the interface functions can only acceptJSobject orJQueryobject, then you need to convert between the two.

1. method of converting jQuery to Dom Object [index] or . Get (Index) :

A,$ ("#form") [index], which gets the Dom object of the form element

b,$ ("#form"). Get (Index)

2 . Convert js dom object to jQuery object, for it is already a Dom Object, you can get a jQuery object simply by wrapping the DOM object with $ () . $ (DOM object ) :

Var A=document.getelementbyid ("form");

$a =$ (a);

After the object conversion, $ A is the encapsulated jquery object that can invoke the jquery encapsulated method

Conversion between a jquery object and a JS native DOM object

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.