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

113
Vistas
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
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