Even before I click the button the h1 tagged element comes yellow what should I do to fix it? Just want to make them yellow when I click on the button.
<html>
<head></head>
<body>
<h1>Hello</h1>
<h2>World</h2>
<h1>test</h1>
<button id="button">click</button>
<script>
var x = document.getElementById("button");
x.addEventListener("onclick",change());
function change(){
var myNodes = document.getElementsByTagName("h1");
for (var i = 0; i < myNodes.length ; i++) {
myNodes[i].style.backgroundColor = "yellow";
}
}
</script>
</body>
</html>