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

152
Views
It's possible to access to specific child type?

I have a file input inside a div, and I would like to access to it, but the file input has no id.

        var el = $("#hey > :file");
    console.log(el);
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<div class="something" id="hey">
  <div class="remote"></div>
  <input type="file">
</div>

But I get a lot of elements, I would like to know if it's possible to do without jQuery.

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

0

<input type="file"> can be matched by the selector input[type="file"], so use that next the #hey >.

You don't need jQuery, querySelector works just fine.

var el = document.querySelector('#hey > input[type="file"]');
console.log(el);

el.onchange = () => {
  console.log(el.files);
};
<div class="something" id="hey">
  <div class="remote"></div>
  <input type="file">
</div>

about 4 years ago · Juan Pablo Isaza Report

0

You can use document.querySelector() to get first match element, or if you need list of all elements use document.querySelectorAll()

var el = document.querySelector('#hey > input[type="file"]');
    console.log(el);
<div class="something" id="hey">
  <div class="remote"></div>
  <input type="file">
</div>

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!