Native JavaScript gets a simple introduction to DOM elements

Source: Internet
Author: User

Native JavaScript gets a simple introduction to DOM elements:

jquery can be used in various ways to get elements, such as ID selectors, class selectors, element selectors, and so on, very convenient.

Here's how to get the functionality of DOM elements using native JS implementations.

I. Get elements by ID:

The most convenient is to use the document.getElementById () function.

Refer to section document.getElementById () for details.

Two. Get elements by tag:

Use the document.getElementsByTagName () function.

Refer to the document.getElementsByTagName () section for details.

Three. Get the element through the Name property:

Use the document.getElementsByTagName () function to implement this function.

Refer to the Document.getelementsbyname () method section for details.

Four. The element is obtained through the class attribute:

Use the Getelementsbyclassname () function to implement this function.

Refer to the Getelementsbyclassname () Usage section for details.

The original address is: http://www.51texiao.cn/javascriptjiaocheng/2015/0723/7021.html

The most original address is: http://www.softwhy.com/forum.php?mod=viewthread&tid=15749

Native JavaScript gets a simple introduction to DOM elements

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.