Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

133
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda