English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية
The mouseenter() method triggers the mouseenter event, or attach a function to be executed when the mouseenter event occurs.
A mouseenter event occurs when the mouse pointer enters the element.
You might think mouseenter,mousemoveandmouseoverThe event is the same, but they are not:
mouseenter-Call only when the mouse pointer enters the element
mousemove-Call when the mouse pointer is moved to the element
mouseover-Call when the mouse pointer enters the element and its child elements (see the following example)
The mouseenter() method is usually used withmouseleave()methods are used together.
Trigger the mouseenter event of the selected element:
$(selector).mouseenter()
Ajouter une fonction à l'événement mouseenter :
$(selector).mouseenter(function)
Changer la couleur de fond lors du déclenchement des événements mouseenter et mouseleave :
$("p").mouseenter(function(){ $(this).css("background-color", "yellow"); }); $("p").mouseleave(function(){ $(this).css("background-color", "lightblue"); });Vérifiez et voyez‹/›
Cet exemple montre la différence entre mousemove, mouseenter et mouseover :
Paramètres | Description |
---|---|
function | Fonction exécutée lors du déclenchement de l'événement mouseenter |