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

161
Views
¿Cómo poner en querySelector algunas ID?
querySelector("#ID1, #ID2, ID#3")

¿Existe la posibilidad de poner en un solo querySelector algunos ID?

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

0

querySelectorAll se puede usar para apuntar a múltiples selectores.

 document.querySelectorAll("#div1, .div2, h3");
about 4 years ago · Juan Pablo Isaza Report

0

El método querySelector() devuelve el primer elemento que coincide con uno o más selectores CSS especificados en el documento.

Tenga en cuenta que para devolver todas las coincidencias, use el método querySelectorAll() en su lugar.

ejemplo

 <div class="bar">.first </div> <div class="bar">.second</div> //get the first element with class bar let firstElement = document.querySelector('.bar'); //log the first match console.log(firstElement) //get all elements with class bar let allElements = document.querySelectorAll('.bar') //You can use any common looping statement to access the matches allElements.forEach(function(elements){ console.log(elements); }); /* querySelector("#ID1, #ID2, ID#3") *select element matches #ID1 *select element matches #ID2 *select element matches #ID3 **/ //select elements matches specified selectors #id1 , #id2 , #id3 and use any common looping statement to access them let allMatchesId = document.querySelectorAll('#id1 , #id2 , #id3'); allMatchesId .forEach(function(elements){ console.log(elements); });

lea los documentos aquí en MDN https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

about 4 years ago · Juan Pablo Isaza Report

0

Simple ! Utilice el siguiente código.

 document.querySelectorAll('#id1, #id2 , #id3');

Esto devolverá la nodelist que puede iterar y puede realizar las acciones que desee.

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!