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

147
Visualizações
Innermost click event called inside the Event listener is not being fired

EDIT with reproducible example, and following T.J. Crowder suggestion below (tnx)

I need a button to be automatically clicked when I click on an element with class 'menu'.

I can get the element on the DOM, length is ok, and when I put a debug watch on it2, all properties seem ok. However, in the application I'm applying it the click event is not fired. In that case the 'menu' items have also their own click event listeners doing their stuff, which might hold the reason. Anyone have an idea why may not be working?

I have a similar working example that I tried, and apparently works

    document.querySelectorAll('.menu').forEach(item => {
        item.addEventListener('click', event => {
         if (document.querySelectorAll('.savebtn').length>0){
         
              var all = document.querySelectorAll('.savebtn');
              var it2=all[0];
              it2.click();       
    
          }
      })
    })
<ul>
<li><a href="http://www.google.com/search?q=1" target="_blank" class="menu" > link 1</a></li>
<li><a href="http://www.google.com/search?q=2"  target="_blank" class="menu"> link 2</a></li>
</ul>



<form action="http://www.google.com/search"  target="_blank">
  
  <input type="text" name ="q">
  <input type="submit" class = "savebtn" value="Submit">
</form>


 

any help ? Thanks

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