This question has already been answered:
Here is just a left example. Why is the function that should be performed on a click just like that?
button = document.getElementsByClassName("button")[0]; block = document.getElementsByClassName("block")[0]; button.onclick = test(); function test(){ block.style.height = "100px"; block.style.background = "red"; }