Skip to content

Latest commit

 

History

History

AddRemoveEventListenerJs

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

AddRemoveEventListenerJs

This recipe shows how to add and remove an event listener to an HTML element.

Expected Behavior:

Browser

Clicking the "Add listener" button will add an event listener to the button. When the main button is clicked, a message will be printed to the console. Clicking the "Remove listener" button will remove that event listener.

Clicking the "Remove 2nd Approach listener" button is self-explanatory.

Make sure to open the console with dev tools first, then reload/refresh the page.