JS get node and edit method

Source: Internet
Author: User

Get:

1.document.getelementbyid ()

Get nodes by ID

2.document.getelementsbyclassname ()

Get a node set (array) by class name

3.document.getelementsbytagname ()

Get a node set (array) by tag name

4.document.createelement ()

Create a new node

5.document.queryselector ()

Get nodes by CSS Selector

6.document.queryselectorall ()

Get node Set (array) by CSS Selector

Edit:

after you get the element node, you can edit the Properties of the operation element node (ID, SRC, className, style, OffsetTop, Offsetwidth, ClientWidth, scrollwidth .... ) and content (InnerHTML, outerhtml, InnerText, Textcontent, ChildNodes, AppendChild, removechild .... ).

It is important to note how the style of Operation is written:

1. The first type is node.style. Style name : For example div.style.height= "100px"( More special: have-style names such as Div.style.backgroundColor, floating div.style.cssFloat)

2. The second type is node.style.cssText : For example, div.style.csstext= "display:block;width:100px;height:100px"

JS get node and edit method

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.