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

116
Views
Why '.tab-content[data-tab=1]' is not a valid selector in JS but valid in jQuery?

I am trying to select a class with a specific attribute in JavaScript, as below:

var me = document.querySelector('.tab-content[data-tab=1]');

But getting the following error:

Uncaught DOMException: Failed to execute 'querySelector' on 'Document': '.tab-content[data-tab=1]' is not a valid selector.

I tried to change it to jQuery:

$('.tab-content[data-tab=1]')

Then it will work.

I tried to change it by adding double quotes:

var me = document.querySelector('.tab-content[data-tab="1"]');

Then it will also work.

I checked the attribute selector at W3 Schools and in its samples, there are [target=_blank], which does not require double quotes.

So why does removing double quotes not work for JavaScript?

about 4 years ago · Juan Pablo Isaza
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!