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

145
Views
¿Es posible acceder a un tipo de niño específico?

Tengo una entrada de archivo dentro de un div y me gustaría acceder a ella, pero la entrada de archivo no tiene identificación.

 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>

Pero obtengo muchos elementos, me gustaría saber si es posible prescindir de jQuery.

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

0

<input type="file"> puede coincidir con el selector input[type="file"] , así que utilícelo junto a #hey > .

No necesita jQuery, querySelector funciona bien.

 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

Puede usar document.querySelector() para obtener el primer elemento coincidente, o si necesita una lista de todos los elementos, 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!