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

262
Views
¿Cómo accede a un tspan dentro de una etiqueta de texto SVG?

He importado un SVG usando y estoy tratando de acceder al <tspan> , porque necesito cambiarlo, pero cuando agrego un id="test" al tspan usando document.getElementById('test'); no da resultado alguno...

¿Como puedó resolver esté problema?

Soy consciente de que puedo cambiar el texto interno usando element.innerText , pero mi resultado es nulo...

Mi SVG:

 <text transform="translate(42.88 166.17)" style="font-size: 12px;font-family: SegoeUI, Segoe UI">Test test<tspan x="135.69" y="0" style="letter-spacing: -0.0634765625em">T</tspan><tspan x="141.38" y="0">esting</tspan><tspan x="0" y="18">Just a test</tspan><tspan x="0" y="36">test</tspan><tspan id="test" x="0" y="72">Change me via JavaScript</tspan></text>

Mi HTML:

 <div class="sidebar"> <object id="sidebartoggle" data="/graphics/test.svg" type="image/svg+xml" onclick="toggleSidebar();" style="top:50%;right:1%;position:fixed;display:flex;justify-content:flex-end;width:500px;transform: translateX(99%); z-index:9999999;" > </object> </div>

Estoy ejecutando el JS en la consola del navegador hasta ahora.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Solo tienes un error tipográfico.

 document.getElementByID('test');

necesita ser

 document.getElementById('test');

entonces debería funcionar bien.

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!