var myDiv = document.getElementById('myDiv'); document.getElementById('myInput').oninput = function() { myDiv.style.backgroundColor = this.value; }