jQuery .mouseout() event

Syntax and Description


.mouseout(handler)           
.mouseout()

handler is a function to execute each time the event is triggered. Return value is the jQuery object, for chaining purposes.

mouseout binds an event handler to the mouseout JavaScript event, or trigger that event on an element.

.mouseout(handler) is a shortcut for .bind('mouseout', handler). .mouseout() is a shortcut for .trigger('mouseout').

We can also trigger the event when another element is clicked.


$('#other').click(function() {
/*from   w  ww  .  j  a v  a2  s  .co  m*/
 $('#outer').mouseout();

});

Listen to mouse out event

The following code adds event handler for mouse out event.


<html>
  <head>
    <script src="http://java2s.com/style/jquery-1.8.0.min.js"></script>
    <script type="text/javascript">
        $(document).ready(function(){<!--from   w  w  w. ja va2 s.  c  o m-->
            $("div").mouseover(function(){
                $(this).append('<span style="color:#F00;">mouseover.</span>');
            }).mouseout(function(){
                $(this).append('<span style="color:#00F;">mouseout</span>');
            });
        });
    </script>
  </head>
  <body>
    <body>
     <div>java2 s.com</div>
    </body>
</html>

Click to view the demo





















Home »
  jQuery »
    jQuery Tutorial »




Basics
Selector
DOM
Event
Effect
Utilities