GlobalEventHandlers.onpointerenter

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.

HTML DOMpointerenter 事件的 GlobalEventHandlers(全局事件处理函数)

js
var enterHandler = targetElement.onpointerenter;

返回值

enterHandler

targetElement的 pointerenter 事件处理函数。

示例

这个例子展示了使用 onpointerenter 来设置元素 pointerenter 事件处理函数的两种方式*。*

js
<html>
<script>
function enterHandler(ev) {
 // 处理 pointerenter 事件
}
function init() {
 var el=document.getElementById("target1");
 el.onpointerenter = enterHandler;
}
</script>
<body onload="init();">
<div id="target1"> 点我 ... </div>
<div id="target2" onpointerenter="enterHandler(event)"> 点我 ... </div>
</body>
</html>

规范

Specification
Pointer Events
# the-pointerenter-event
Pointer Events
# dom-globaleventhandlers-onpointerenter

浏览器兼容性

BCD tables only load in the browser

参见