The difference between a sharp jquery--dom object and a jquery object

Source: Internet
Author: User

  Dom Object

var Pname=document.getelementbyid ("id");

Pname.innerhtml= ""; Enter content into the page

 jquery Object

Objects produced after wrapping Dom objects with jquery

For example:

$ ("#foo"). HTML () is equivalent to document.getElementById ("foo"). InnerHTML

However, the methods of the two objects are different from each other.

  

Dom object converted to jquery object

var My=document.getelementbyid ("foo");

var $my =$ (my);

jquery objects converted to DOM objects

(1), jquery object is an array-like object, you can get the corresponding Dom object by means of [index]

var $my =$ ("#my"); jquery Object

var my= $my [0]; Dom Object

Alert (my.checked)//Check if the checkbox is selected

(2), get the corresponding DOM object by the Get (index) method

var $my =$ ("my"); jquery Object

var my = $my. Get (0); Dom Object

alert (my.checked); Check if this checkbox is selected

  

The difference between a sharp jquery--dom object and a jquery 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.