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

273
Views
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 answers
Answer question

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 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!