Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

274
Visualizações
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 Respostas
Responde à pergunta

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda