Element:pointerover 事件

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2020.

The pointerover event is fired when a pointing device is moved into an element's hit test boundaries.

语法

var overHandler = targetElement.onpointerover;

返回值

overHandler

pointerover 事件处理器返回目标元素的overHandler.

案例

这里使用两种方式展示了如何去使用 onpointerover 去设置一个元素的 pointerover 事件处理器

js
<html>
<script>
function overHandler(ev) {
 // Process the pointerover event
}
function init() {
 var el=document.getElementById("target1");
 el.onpointerover = overHandler;
}
</script>
<body onload="init();">
<div id="target1"> Touch me ... </div>
<div id="target2" onpointerover="overHandler(event)"> Touch me ... </div>
</body>
</html>

规范

Specification
Pointer Events
# the-pointerover-event
Pointer Events
# dom-globaleventhandlers-onpointerover

浏览器兼容性

BCD tables only load in the browser

参见