Use the id attribute to manipulate text with JavaScript: - HTML CSS HTML Global Attribute

HTML CSS examples for HTML Global Attribute:id

Description

Use the id attribute to manipulate text with JavaScript:

Demo Code

ResultView the demo in separate window

<html>
<body>

<h1 id="myHeader">Hello World!</h1>
<button onclick="displayResult()">Change text</button>

<script>
function displayResult() {<!--from  www.  j a  v  a 2 s . co m-->
    document.getElementById("myHeader").innerHTML = "Have a nice day!";
}
</script>

</body>
</html>

Related Tutorials