Learn how to remove JavaScript event listeners attached to HTML elements

JavaScript provides a built-in function called removeEventListener() that you can use to remove event listeners attached to HTML elements. Suppose you have an event listener attached to a <button> element as follows:

<body>
  <button id="save">Save</button>
  <script>
    let button = document.getElementById("save");

    function fnClick(event) {
      alert("Button save is clicked");
    }

    button.addEventListener("click", fnClick);
  </script>
  <body></body>
</body>

#javascript #html

How to Remove JavaScript Event Listeners Attached to HTML Elements
1.60 GEEK