{"name":"hover","type":"method","title":".hover()","deprecated":null,"removed":null,"desc":"Bind one or two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.","categories":["events/mouse-events","version/1.0"],"entries":[{"return":"jQuery","signatures":{"added":"1.0","argument":[{"desc":"A function to execute when the mouse pointer enters the element.","name":"handlerIn(eventObject)","type":"Function"},{"desc":"A function to execute when the mouse pointer leaves the element.","name":"handlerOut(eventObject)","type":"Function"}]},"examples":[{"desc":"To add a special style to list items that are being hovered over, try:","code":"\n$( \"li\" ).hover(\n function() {\n $( this ).append( $( \" ***\" ) );\n }, function() {\n $( this ).find( \"span:last\" ).remove();\n }\n);\n\n$( \"li.fade\" ).hover(function() {\n $( this ).fadeOut( 100 );\n $( this ).fadeIn( 500 );\n});\n","css":"\n ul {\n margin-left: 20px;\n color: blue;\n }\n li {\n cursor: default;\n }\n span {\n color: red;\n }\n","html":"\n\n"},{"desc":"To add a special style to table cells that are being hovered over, try:","code":"\n$( \"td\" ).hover(\n function() {\n $( this ).addClass( \"hover\" );\n }, function() {\n $( this ).removeClass( \"hover\" );\n }\n);\n"},{"desc":"To unbind the above example use:","code":"\n$( \"td\" ).off( \"mouseenter mouseleave\" );\n"}],"desc":"Bind two handlers to the matched elements, to be executed when the mouse pointer enters and leaves the elements.","longdesc":"\n

The .hover() method binds handlers for both mouseenter and mouseleave events. You can use it to simply apply behavior to an element during the time the mouse is within the element.

\n

Calling $( selector ).hover( handlerIn, handlerOut ) is shorthand for:

\n
\n$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );\n      
\n

See the discussions for .mouseenter() and .mouseleave() for more details.

\n "},{"return":"jQuery","signatures":{"added":"1.4","argument":{"desc":"A function to execute when the mouse pointer enters or leaves the element.","name":"handlerInOut(eventObject)","type":"Function"}},"examples":{"desc":"Slide the next sibling LI up or down on hover, and toggle a class.","code":"\n$( \"li\" )\n .filter( \":odd\" )\n .hide()\n .end()\n .filter( \":even\" )\n .hover(function() {\n $( this )\n .toggleClass( \"active\" )\n .next()\n .stop( true, true )\n .slideToggle();\n });\n","css":"\n ul {\n margin-left: 20px;\n color: blue;\n }\n li {\n cursor: default;\n }\n li.active {\n background: black;\n color: white;\n }\n span {\n color:red;\n }\n","html":"\n\n"},"desc":"Bind a single handler to the matched elements, to be executed when the mouse pointer enters or leaves the elements.","longdesc":"\n

The .hover() method binds handlers for both mouseenter and mouseleave events. You can use it to simply apply behavior to an element during the time the mouse is within the element.

\n

Calling $( selector ).hover( handlerIn, handlerOut ) is shorthand for:

\n
\n$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );\n      
\n

See the discussions for .mouseenter() and .mouseleave() for more details.

\n "}]}