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 that mouseenter,mousemoveandmouseoverThe event is the same, but they are not:
mouseenter-Called only when the mouse pointer enters the element
mousemove-Called when the mouse pointer is moved to the element
mouseover-Called when the mouse pointer enters the element and its child elements (see the example below)
The mouseenter() method is usually used withmouseleave()methods together.
Trigger the mouseenter event of the selected element:
$(selector).mouseenter()
Anexar função ao evento mouseenter
$(selector).mouseenter(function)
Mudar a cor de fundo ao acionar os eventos mouseenter e mouseleave
$("p").mouseenter(function(){ $(this).css("background-cor", "yellow"); }); $("p").mouseleave(function(){ $(this).css("background-cor", "lightblue"); });Teste e veja‹/›
Este exemplo demonstra a diferença entre mousemove, mouseenter e mouseover:
Parâmetro | Descrição |
---|---|
function | Função executada ao ser acionado o evento mouseenter |