Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

163
Vistas
How to put into querySelector some IDs?
querySelector("#ID1, #ID2, ID#3")

Is there a possibility to put into one querySelector some IDs?

about 4 years ago · Juan Pablo Isaza
3 Respuestas
Responde la pregunta

0

querySelectorAll can be used to target multiple selectors.

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

0

The querySelector() method returns the first element that matches a specified CSS selector(s) in the document.

Keep in mind that to return all the matches, use the querySelectorAll() method instead.

example

<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);
});

read the docs here at MDN https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelectorAll

about 4 years ago · Juan Pablo Isaza Denunciar

0

Simple ! Use following code.

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

This will return nodelist which you can iterate and can perform actions that you want.

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda