off
Using the off method can unregister an event handler that has been registered, thereby canceling the listening to the event.
Below is an example demonstrating how to use the off method to remove an event listener:
-
In this example, we registered a click event handler f. When the button is clicked, the event handler displays the click count in #logger. Using the off method, we removed the event listener when the click count reaches 3.