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

235
Views
JS DOM: How to access nested element

It's very tricky question, but please can someone help me with it?

Let's suppose we have code, similar to that:

<div id='main'>

<div class='class1'>
<div class='class2'>
<div class='class3'>
<div class='class4'>
<div class='class5'>
<div class='class6'>
<div class='class7'>
<div class='class8'>

<button class='button'/>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>

Is there any way to access button inside these elements?

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You can use document.querySelector() to select elements just like you would with CSS, in your case:

document.querySelector("#main button")
about 4 years ago · Juan Pablo Isaza Report
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!