Home > Article > Web Front-end > What is the function of hover method in jquery
The hover method in jquery specifies two functions to be run when the mouse pointer hovers over the selected element. Its usage syntax is "$(selector).hover(inFunction,outFunction)".
The operating environment of this article: windows7 system, jquery3.2.1 version, DELL G3 computer
#What is the function of the hover method in jquery?
jQuery hover() method:
hover() method specifies two functions to be run when the mouse pointer hovers over the selected element.
Method triggers mouseenter and mouseleave events.
Note: If only one function is specified, both mouseenter and mouseleave will execute it.
Syntax
$(selector).hover(inFunction,outFunction)
Call:
$( selector ).hover( handlerIn, handlerOut )
Equivalent to the following:
$( selector ).mouseenter( handlerIn ).mouseleave( handlerOut );
Note: If only one function is specified, it will be in mouseenter and Run on mouseleave event.
Call:
$(selector).hover(handlerInOut)
Equivalent to:
$( selector ).on( "mouseenter mouseleave", handlerInOut );
Parameters
inFunction required. Specifies the function to run when the mouseenter event occurs.
outFunction Optional. Specifies the function to run when the mouseleave event occurs.
Recommended learning: "jquery video tutorial"
The above is the detailed content of What is the function of hover method in jquery. For more information, please follow other related articles on the PHP Chinese website!