Handle onMouseOver event - Javascript DOM

Javascript examples for DOM:Mouse Event

Description

Handle onMouseOver event

Demo Code

ResultView the demo in separate window

<html>
   <head> 
      <meta name="viewport" content="width=device-width, initial-scale=1"> 
      <style id="compiled-css" type="text/css">

#box {//from  w  ww  .j av a2  s  .  co m
   width: 100px;
   height: 100px;
}


      </style> 
      <script type="text/javascript">
    window.onload=( function() {
var x = document.getElementById('box');
x.onmouseover=function(){
    this.style.backgroundColor='lightgreen';
}
    });

      </script> 
   </head> 
   <body> 
      <div id="box" style="background-color:red;"></div>  
   </body>
</html>

Related Tutorials