Please note, this is a STATIC archive of website www.w3schools.com from 05 May 2020, cach3.com does not collect or store any user information, there is no "phishing" involved.
THE WORLD'S LARGEST WEB DEVELOPER SITE

jQuery hover() Method

❮ jQuery Event Methods

Example

Change the background color of a <p> element when the mouse pointer hovers over it:

$("p").hover(function(){
  $(this).css("background-color", "yellow");
  }, function(){
  $(this).css("background-color", "pink");
});
Try it Yourself »

Definition and Usage

The hover() method specifies two functions to run when the mouse pointer hovers over the selected elements.

This method triggers both the mouseenter and mouseleave events.

Note: If only one function is specified, it will be run for both the mouseenter and mouseleave events.


Syntax

$(selector).hover(inFunction,outFunction)

Parameter Description
inFunction Required. Specifies the function to run when the mouseenter event occurs
outFunction Optional. Specifies the function to run when the mouseleave event occurs

❮ jQuery Event Methods