<div id="mydiv">foo</div> <script> document.getElementById("mydiv").onmouseover = function() { this.style.backgroundColor = "blue"; } </script>