.hover( handlerIn, handlerOut )
The method hover() is a shorthand of :
Syntax:$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );
$( selector ).hover( handlerIn, handlerOut )Example:
$( "p" ).hover(
function() { // Mouse enters the
$( this ).addClass( "hover" );
}, function() { // Mouse exits zone
$( this ).removeClass( "hover" );
}
);
.hover( handlerInOut )
This method is useful when the same processing is repeated for both the input and output events of the target element area. We won't need to copy the code into both the input and output event functions.Syntax:
$(selector).hover(handlerInOut)When passing a single function to the hover(), it will execute two events, mouseenter and mouseleave. This allows the jQuery user to use the different failover methods in the handler or respond differently depending on event.type.
Example:
$( selector ).on( "Mouse pointer in and out of box", handlerInOut );
References:
https://api.jquery.com/hover/
Commentaires (0)
Laisser un commentaire
Connectez-vous pour commenter
Rejoignez la discussion et partagez vos connaissances avec la communauté
Chargement des commentaires...