Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / HTML

onmouseenter — handling mouse pointer entry

The global HTML attribute onmouseenter specifies JavaScript to run for the mouseenter event when the mouse pointer enters an element.

Version: WHATWG HTML Living Standard; index snapshot date recorded separately

Syntax

onmouseenter="JavaScript statements"

onmouseenter is a global HTML event-handler attribute. Its value is a JavaScript function body, not an event name or URL. It corresponds to the mouseenter event.

Inside the attribute code, this refers to the element and event exposes the event. The JavaScript property element.onmouseenter accepts a function or null, not code text; assigning a function replaces the existing handler in that slot.

In the example, pointer entry changes the button label. Content Security Policy can block inline attribute handlers. Do not make essential functionality depend exclusively on mouse hover.

Examples

<!doctype html>
<html lang="en">
<meta charset="utf-8">
<title>onmouseenter example</title>
<button type="button" onmouseenter="this.textContent = 'Entered'">Enter here</button>
</html>

Result

Entered

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources