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

309
Views
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 answers
Answer question

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 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!