HTML DOM access


  Translation results:

Access HTML DOM - Find HTML elements.

HTML DOM accesssyntax

Accessing HTML elements is equivalent to accessing nodes

You can access HTML elements in different ways:

By using the getElementById() method

By using getElementsByTagName() Method

By using getElementsByClassName() Method

HTML DOM accessexample

<!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