off
Using the off method can unregister an already-registered event handler to stop listening for the event.
Below is an example demonstrating how to use the off method to remove event listeners:
-
In this example, we register a click event handler f. When the button is clicked, the event handler displays the click count in #logger. Using the off method, we cancel the event listener when the click count reaches 3.