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

314
Vistas
querySelectorAll with including AND excluding attribute conditions (both)

The task is to find all elements which have values in "href" attribute, which suit 2 conditions at the same time:

  1. they contain :// string
  2. they not starting with http://internal.com string

So I need something like

const targetHrefs = document.querySelectorAll('[name="list"] ~ ul > li > a[href*="://"][href^="http://internal.com"]');

where the 2nd condtion should be with operator NOT

Is it possible using the only CSS Selector rule?

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

0

Just put it in a :not?

const targetHrefs = document.querySelectorAll('a[href*="://"]:not([href^="http://internal.com"])');
console.log(targetHrefs.length);
console.log(targetHrefs[0]);
<a href="foo"></a>
<a href="https://example.com/"></a>
<a href="http://internal.com/"></a>

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