Javascript Event How to - Handle mouse out and hover event








Question

We would like to know how to handle mouse out and hover event.

Answer


<!DOCTYPE html>
<html>
<head>
</head><!--  w  w  w. j av  a  2s .c o m-->
<body>
  <a href="#" onMouseOut="goHo('????')" onMouseOver="goHo('60-180')">Mouseover
    me</a>
  <h1 id="hu"></h1>
  <script type='text/javascript'>
    function goHo(html) {
       document.getElementById('hu').innerHTML=html;
    }
    
    </script>
</body>
</html>

The code above is rendered as follows: