Javatpoint Logo

91-9990449935

 0120-4256464

jQuery hover()

The jQuery hover() method executes two functions when you roam the mouse pointer over the selected element. The hover() method triggers both the mouseenter and mouseleave events.

Syntax:

Note: If you specify only one function then it will be run for both the mouseenter and mouseleave event.

Parameters of jQuery hover() event

ParameterDescription
InFunction It is a mandatory parameter. It is executed the function when mouseenter event occurs.
OutFunction It is an optional parameter. It is executed the function when mouseleave event occurs.

jQuery hover() example

Let's take an example to see the hover () effect. In this example, when you hover your mouse pointer over the selected element the the background color of that selected element will be changed.

Test it Now

Output:

Hover your mouse pointer on me!

Note: In the above example, the background color of the selected element is violet for mouseenter event and green for mouseleave event.

jQuery hover() example 2

Let's see another example of hover() event with the combination of fadeIn and fadeOut effects.

Test it Now
Next TopicjQuery mousedown()