document.querySelector("#myInput").addEventListener("keyup", function (e) { document.querySelector("#myDiv").style.background = e.target.value; });