event.defaultPrevented
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
概述
返回一个布尔值,表明当前事件是否调用了 event.preventDefault()
方法。
备注:
你应该使用该属性来代替以前的非标准的已经被废弃的getPreventDefault()
方法 (查看Firefox bug 691151).
语法
js
bool = event.defaultPrevented;
示例
js
if (e.defaultPrevented) {
/* 事件的默认动作已被取消*/
}
规范
Specification |
---|
DOM # ref-for-dom-event-defaultprevented① |
浏览器兼容性
Report problems with this compatibility data on GitHubdesktop | mobile | server | ||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
defaultPrevented |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
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.