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 Attribute |
Type
: |
html |
Category
: |
Web Tutorial |
Sub Category
: |
HTML Attribute |
Uploaded by
: |
Admin |