HTML DOM Methods

Source: Internet
Author: User

Methods are actions that we can perform on a node (HTML element).

Programming interface

The HTML DOM can be accessed through JavaScript (and other programming languages).

All HTML elements are defined as objects, while programming interfaces are object methods and object properties.

Methods are actions that you can perform (such as adding or modifying elements).

A property is a value that you can get or set (such as the name or content of a node).

getElementById () method

The getElementById () method returns the element with the specified ID:

Example
<!DOCTYPE HTML><HTML><Body><PID= "Intro">Hello world!</P><P>This example demonstrates<b>getElementById</b>Method!</P><Script>x=document.getElementById ("Intro");d Ocument.write ("<p> Text from the intro paragraph:" +x.innerhtml+ "</p>");</Script></Body></HTML>
View results:

Hello world!

This example demonstrates the getElementById Method!

Text from the intro paragraph: Hello world!

HTML DOM objects-Methods and properties

Some common HTML DOM methods:

    • getElementById (ID)-Gets the node (element) with the specified ID
    • AppendChild (node)-Insert a new child node (element)
    • RemoveChild (node)-Delete child nodes (elements)

Some common HTML DOM properties:

    • InnerHTML-Text value of the node (element)
    • ParentNode-parent node of the node (element)
    • ChildNodes-Child nodes of nodes (elements)
    • Attributes-node (element) attribute node

Some DOM object methods

HTML DOM Methods

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.