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

176
Views
document.querySelector select inner div in following element

I am trying to make the following query work:

let itemName = "Fancy-item-name"
document.querySelector(`a[href*=${itemName}] + div.ugly-class-wrapper > div.second-ugly-class > div.first-button`);

i tried as well, nextSibling option, but returning undefined for the query.

What am I doing wrong?

the html is following:

<div> 
  <a class="some-ugly-class" aria-label="Fancy-item-name" href="/item/fancy-item-name">Fancy item</a>

  <div class="ugly-class-wrapper">
    <div class="first-ugly-class"></div>
    <div class="second-ugly-class">
      <button type="button" class="first-button"></button>
      <button type="button" class="second-button"></button>
    </div>
  </div>
</div>

i am trying to click the second button <button type="button" class="second-button"></button>, by using a href above, which is always dynamic.

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!