English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

jQuery mouseenter() method

Evento do jQuery

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.

Syntax:

Trigger the mouseenter event of the selected element:

$(selector).mouseenter()

Anexar função ao evento mouseenter

$(selector).mouseenter(function)

Exemplo

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:

Evento de mouseenter acionado:

Evento de mousemove acionado:

Evento de mouseover acionado:

Executar Código

Valor do Parâmetro

ParâmetroDescrição
functionFunção executada ao ser acionado o evento mouseenter

Evento do jQuery