Dom Objects and jquery objects

Source: Internet
Author: User

1. Dom Object

Document Object model. All elements are accessible through the HTML DOM

Get the method: 1. Find the element document.getElementById ("id") by ID

2. Find the Element object collection by tag name document.getElementsByTagName ("");

3. Find the Element object collection by name Document.getelementsbyname (name);

2. jquery Object

The object created after wrapping the DOM object with jquery is unique to jquery. If an object is a jquery object, then you can use the method in jquery.

Note: jquery objects cannot use any of the DOM object's methods, and vice versa.

The two can use the method of the object by converting to each other.

1.Dom objects into jquery objects

For a DOM object, you only need to wrap the DOM object with $ () to get a jquery object.

var domobj = document.getElementById ("zero"); Dom object var $zero = $ (domobj); jquery Object

2.jQuery objects turn into DOM objects

The 1.jQuery object is an array object that can be obtained by using the [index] method of the DOM object

var $zero = $ ("#zero"); var zero = $zero [0];console.log (zero.innerhtml);

2. Through get (index);

var $top = $ (". Top"), var top = $top. Get (0); Console.log (top.innerhtml);

Dom Objects and jquery 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.