The id Attribute: Using The id Attribute in JavaScript
Using The id Attribute in JavaScript
<script>
function displayResult() {
document.getElementById("myHeader").innerHTML = "Have a nice day!";
}
</script>
JavaScript can access an element with a specified id by using the getElementById() method.