<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<body>
<button id="btn1">添加监听事件</button>
<button id="btn2">移除监听事件</button>
<div id="box3" style="width:150px;height:150px;background:pink"></div>
<script>
document.getElementById('btn1').addEventListener("click", fn3)
document.getElementById('btn2').onclick = function () {
document.getElementById('box3').removeEventListener("click", fn3)
}
function fn3() {
document.getElementById('box3').onclick = function () {
alert(11111)
}
}
</script>
</body>
</html>