Skip to content

Files

Latest commit

080eace · Aug 12, 2022

History

History

AddRemoveEventListenerJs

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.