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

275
Vistas
How can I replace text in multiple svg files with one code?

I am using the same SVG file twice within the page. I'm trying to change a text inside SVGs based on the language of the page. With the code below, only the text in one SVG file changes and the other does not. What do I need to do to change it in all SVGs?

SVG code:

<text id="trading-text" class="text1" dx="0" dy="0" transform="translate(-100,0)" fill="#444351">DEFAULT TEXT</text>

JS Code:

let text = "CHANGE TEXT"; 
document.querySelector('[id="trading-text"]').innerHTML= text;
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I could not get what you really mean by svg file. You also should not have more than one element with the same ID! So add a className like change-text to each text and use the following code:

const text = "CHANGE TEXT"; 

document.querySelectorAll('.change-text').forEach((node) => {
  node.textContent= text
});

Good luck.

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