PointerEvent.pointerId - Web APIs 编辑
The pointerId
read-only property of the PointerEvent
interface is an identifier assigned to a given pointer event. The identifier is unique, being different from the identifiers of all other active pointer events. Since the value may be randomly generated, it is not guaranteed to convey any particular meaning.
Syntax
var id = pointerEvent.pointerId;
Return value
id
- The pointer event's unique identifier number.
Example
The following code snippet compares a previously saved pointerId
with the one of the pointerdown
event that was just fired.
let id; // Let's assume that this is a previously saved pointerId
target.addEventListener('pointerdown', function(event) {
// Compare previous event's ID that was cached
// to current event's ID and handle accordingly
if (id === event.pointerId) process_event(event);
}, false);
Specifications
Specification | Status | Comment |
---|---|---|
Pointer Events – Level 2 The definition of 'pointerId' in that specification. | Recommendation | Non-stable version. |
Pointer Events The definition of 'pointerId' in that specification. | Obsolete | Initial definition. |
Browser compatibility
BCD tables only load in the browser
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论