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

126
Vistas
Find what happens when you click an HTML button

For example, you have this script that adds an event listener to a button like this:

document.getElementById("myBtn").addEventListener("click", function() {
  document.getElementById("demo").innerHTML = "Hello World";
});

How would I see that code in a website, so I can execute the code from the console?

about 4 years ago · Juan Pablo Isaza
2 Respuestas
Responde la pregunta

0

You want to trigger the event from the console. But that is not possible. However, you can call an external function in the second parameter of the EventListener. This function is then in the global scope. You can then trigger the action in the console with the function name that would otherwise be triggered via the click.

makeAction();

document.getElementById("myBtn").addEventListener("click", function() {
  makeAction();
});

function makeAction() {
  console.log('triggered')
  document.getElementById("demo").innerHTML = "Hello World";
}
<button id="myBtn">click</buton>
<div id="demo"></div>

about 4 years ago · Juan Pablo Isaza Denunciar

0

On Chrome, you can open developer tools, select the element, then select the 'Event Listeners' tab:

enter image description here

Which will show you the event listeners bound to the element:

enter image description here

about 4 years ago · Juan Pablo Isaza 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