Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

259
Vistas
How can I remove every listener from a page?

I know how to remove a listener from an element, but how can I remove every event listener from every element on the page?

A jQuery and pure JS solution would be nice.

about 4 years ago · Santiago Trujillo
3 Respuestas
Responde la pregunta

0

I would suggest to look into the .off function of jQuery. Also, based on this stackoverflow question, I would try to remove all every listeners with the following code

$("body").find("*").off();

Hope this could help you.

about 4 years ago · Santiago Trujillo Denunciar

0

You can try this too.

http://jsfiddle.net/LkfLezgd/9/

$("#cloneButton").click(function() {
$('body').replaceWith($('body').clone().html());
});
about 4 years ago · Santiago Trujillo Denunciar

0

You can loop through the form elements as below to remove the event listeners at your preferred way.

The fastest way to do this is to just clone the node which will remove all event listeners but this won't remove if 'onclick' attribute is used.

document.getElementById('button').addEventListener('click', onClick, false);

function onClick() {
   console.log('Form clicked');
   var form = document.getElementById('myForm');

   for(var i = 0; i < form.elements.length; i++){
       var elm = form.elements[i];
       removeEvents(elm);
   }
}

function removeEvents(elm) {
  // The fastest way to do this is to just clone the node, which will remove all event listeners:

   var new_element = elm.cloneNode(true);
   elm.parentNode.replaceChild(new_element, elm);
}
<form id="myForm">
   <input id="button" type="button" value="Click" />
</form>

about 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda