<div id="div" style="background-color:black">LOL</div> <script> var div = document.getElementById("div"); div.onmouseover = function(){ this.setAttribute("style","background-color:red;"); } </script>