Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

139
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!