document.removeEventListener() 예제
<button onclick="eventRemover()">클릭</button> <p id="demo"></p> <script> document.addEventListener("mousemove", homzzang); function homzzang() { document.getElementById("demo").innerHTML = Math.random(); } function eventRemover() { document.removeEventListener("mousemove", homzzang); } </script> 결과보기
<button onclick="eventRemover()">클릭</button>
<p id="demo"></p>
<script>
document.addEventListener("mousemove", homzzang);
function homzzang() {
document.getElementById("demo").innerHTML = Math.random();
}
function eventRemover() {
document.removeEventListener("mousemove", homzzang);
</script>
결과보기