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

311
Vistas
How do I use querySelector with data attribute and class both?

My html looks like this

<div class="slds-col slds-size_1-of-1 slds-hide" data-controllinganswer="a1ZC2000000O2n3MAC" data-questionid="a1fC20000000VgXIAU" data-id="a1fC20000000VmzIAE" data-selectedanswer="a1ZC2000000O2zxMAC">

But when I try to do this

this.template.querySelector('[data-id="' + e.dataset.id + '"], .slds-show')

It still returns me an element, even though there is no class as slds-show. Is this the right way of using queryselector with multiple attributes?

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

0

The comma selector1, selector2 says that elements having selector1 or selector2 should match.

If you have a space selector1 selector2 it will match an element matching selector2 inside an element matching selector1, if you have selector1selector2 without space, then it matches only an element that matches both selector1 and selector2.

So your selector should be

this.template.querySelector('[data-id="' + e.dataset.id + '"].slds-show')
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