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

355
Vistas
HTML tag Attribute selector with colon, wildcard

I have the following element:

<page-title xml:lang="x-default">Text</page-title>

I need to be able to select it by its attribute as a have a list of tags, that I need to select individually.

The issue is I cannot select the element with:

page-title[xml:lang="x-default"]

As the ":" colon seems to break the attribute as its probably not a valid character to use. I know that you can use wildcard selectors for the value of the attribute such as * for containing and ^ for begins with, and so on.

My question is, is it possible to build a selector which uses wildcard not for the attribute value but for the attribute name itself? such as:

page-title[*lang="x-default"]

For a selector which would get a element with an attribute name containing "lang" which has a value of "x-default"?

Can this perhaps somehow be done with JavaScript? I also have jQuery available if that would be an option.

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

0

To escape a character in a jQuery/JS selector you can use \\:

$('page-title[xml\\:lang="x-default"]').addClass('jquery'); // jquery

document.querySelector('page-title[xml\\:lang="x-default"]').classList.add('native'); // native
.jquery { color: #C00; }
.native { text-decoration: underline; }
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.6.0/jquery.min.js"></script>
<page-title xml:lang="x-default">Text</page-title>

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