document.querySelector("#myInput").addEventListener("keyup", function (e) { document.querySelector("#myDiv").style.background = e.target.value; });
var myDiv = document.getElementById('myDiv'); document.getElementById('myInput').oninput = function() { myDiv.style.backgroundColor = this.value; }