<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<button id="btn">clicl me</button>
<button id="rmBtn">remove</button>
<script>
var btn = document.getElementById("btn");
var rmBtn = document.getElementById("rmBtn");
// 注册 btn 元素的 DOM0 级事件处理程序
btn.onclick = function (e) {
var ev = e || event;
console.log(ev);
}
// 移除 button#btn 元素 dom0 级事件处理程序
rmBtn.onclick = function () {
btn.onclick = null;
}
</script>
</body>
</html>
06-19
423
![](https://csdnimg.cn/release/blogv2/dist/pc/img/readCountWhite.png)