Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Remove Event Listener of Button

How do I remove the event listener, so the alert box will not be popped up anymore after Remove Listener to prevent it from triggering pop_up button is clicked?

document.querySelector('#hihi-toggle').addEventListener('click', e => {
  alert("I am Jim")
});

function remove_event_listener_button() {
  //document.querySelector('#hihi-toggle').removeEventListener()
}
<button id="hihi-toggle" data-enabled="false">Alert Box </button>
<button onclick="remove_event_listener_button()">Remove Listener to prevent it from triggering pop_up</button>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

const eventHandler = e => alert("I am Jim");

document.querySelector('#hihi-toggle').addEventListener('click', eventHandler);

function remove_event_listener_button() {
  document.querySelector('#hihi-toggle').removeEventListener('click',eventHandler)
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading