GlobalEventHandlers.onmouseover

The onmouseover property of the GlobalEventHandlers mixin is an event handler that processes mouseover events.

The mouseover event fires when the user moves the mouse over a particular element.

Syntax

element.onmouseover = function;

Example

This example adds an onmouseover and an onmouseout event to a paragraph. Try moving your mouse over and out of the element.

HTML

<p>Test your mouse on me!</p>

JavaScript

const p = document.querySelector('p');
p.onmouseover = logMouseOver;
p.onmouseout = logMouseOut;

function logMouseOver() {
  p.textContent = 'MOUSE OVER detected';
}

function logMouseOut() {
  p.textContent = 'MOUSE OUT detected';
}

Result

Specifications

Specification
HTML Standard
# handler-onmouseover

Browser compatibility

BCD tables only load in the browser