How do I make the color of the box be the value of the input?
box = document.getElementById("box");
typeColor = document.getElementById("typeColor");
function changeBoxColor() {
box.style.backgroundColor = typeColor;
}
//box is a div, typeColor is an input
body {
margin: 0px;
}
#box {
width: 100px;
height: 100px;
background-color: grey;
margin-left: 100px;
margin-top: 50px;
}
<input id="typeColor" placeholder="Type a color...">
<button onclick="changeBoxColor()">Change Box Color</button>
<div id="box">
</div>