Example:
HTML
<!DOCTYPE HTML>
<html>
<body>
<h1 id="myHeader">Hello World!</h1>
<button onclick="displayResult()">Change text</button>
<script>
function displayResult() {
document.getElementById("myHeader").innerHTML = "Have a nice day!";
}
</script>
</body>
</html>
How to Use the id attribute to manipulate text with JavaScript | HTML Global Attributes |
How to Use the id attribute to link to an element with a specified id within a page | HTML Global Attributes |
How to Use the id attribute to style text with CSS | HTML Global Attributes |
Type: | Html |
Category: | Web Tutorial |
Sub Category: | HTML Global Attributes |
Uploaded by: | Admin |