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

87
Views
Javascript si svg tiene clase de rol agregado

Estoy tratando de agregar una clase a un SVG si no tiene un rol = "img".

Puedo agregar una clase al SVG con rol img

 const imgRole = document.querySelectorAll('svg[role="img"]'); imgRole.forEach(function(el) { el.classList.add("my--class"); });

Sin embargo, no puedo apuntar a los SVG que no tienen el rol.

Traté de encontrar una forma de usar not !, pero no tuve éxito.

if (!el.classList.contains...

Agradecería cualquier ayuda para mostrarme cómo lograr esto.

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Intenta usar :not

 document.querySelectorAll('p:not([role=a])').forEach(p => p.style.color = 'red')
 <p role="a">lorem ipsum</p> <p role="not a">lorem ipsum</p> <p role="a">lorem ipsum</p> <p role="also not a">lorem ipsum</p>

En tu caso:

 'svg:not([role="img"])'
about 4 years ago · Santiago Trujillo 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!