HTML DOM methods


  Translation results:

HTML DOM methods are actions we can perform on nodes (HTML elements).

HTML DOM attributes are values ​​that we can set and modify on nodes (HTML elements).

HTML DOM methodssyntax

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

All HTML elements are defined as objects, and the programming interface is object methods and object properties.

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

Attributes are values ​​that you can get or set (such as the name or content of a node).

HTML DOM methodsexample

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
</head>
<body>

<p id="intro">Hello World!</p>
<p>这个实例演示了 <b>getElementById</b> 方法!</p>

<script>
x=document.getElementById("intro");
document.write("<p>段落的文本为: " + x.innerHTML + "</p>");
</script>

</body>
</html>

Run instance »

Click the "Run instance" button to view the online instance

Popular Recommendations

Home

Videos

Q&A