Am I using setAttribute correctly? When I click reset after say clicking "blue" button, box has no color but it seems like it is still setting the height to 150px. What am i doing wrong here?
document.getElementById("button1").addEventListener("click", function() {
document.getElementById("box").style.height = "250px";
});
document.getElementById("button2").addEventListener("click", function() {
document.getElementById("box").style.backgroundColor = "blue";
});
document.getElementById("button4").addEventListener("click", function() {
document.getElementById("box").setAttribute("style", "backgroundColor: orange; height:150px");
});
<div id="box" style="height:150px; width:150px; background-color:orange; margin:25px"></div>
<button id="button1">Grow</button>
<button id="button2">Blue</button>
<button id="button3">Fade</button>
<button id="button4">Reset</button>