JavaScript DOM objects and jquery objects are converted to each other

Source: Internet
Author: User

1. Analysis of source code

<! DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 transitional//en" "Http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd ">
2. Operation Result

(1) initialization



(2) Click the "JavaScript Dom object to convert to jquery object" button



(3) Click " jquery objects converted to JavaScript DOM objects "button



3. Analysis and explanation

(1) JavaScript DOM object converted to jquery object

//dom Object
var divobject = document.getElementById ("Div_body");
jquery Object
var $divObject = $ (divobject);


(2) JQuery object converted to JavaScript DOM object

Method One:

//jquery Object
var $divObject = $ ("#div_body");
Dom Object
var divobject = $divObject [0];


Method Two:

//jquery Object
var $divObject = $ ("#div_body");
Dom Object

var divObject1 = $divObject. Get (0);

JavaScript DOM objects and jquery objects are converted to each other

Related Article

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.