jQuery Event How to - Handle mouse leave event








Question

We would like to know how to handle mouse leave event.

Answer


<!DOCTYPE html>
<html>
<head>
<script type='text/javascript'
  src='http://code.jquery.com/jquery-1.9.1.js'></script>
<script type='text/javascript'>
$(function(){<!--  w w  w.j  a va2  s . co  m-->
    $("#about").mouseleave(function () {
        $(this).css("background", 'transparent url("http://www.java2s.com/style/download.png") no-repeat top left');
    });
});
</script>
</head>
<body>
  <div id="about">About</div>
</body>
</html>

The code above is rendered as follows: