【问题标题】:Unable to replace SVG tspan in IE/Edge [duplicate]无法在 IE/Edge 中替换 SVG tspan [重复]
【发布时间】:2017-01-28 19:24:42
【问题描述】:

我有以下 JSFiddle:https://jsfiddle.net/8dc9ww9a/

这是在我的 HTML 中找到的 SVG:

<svg viewbox="0 0 100 100">
  <circle cx="50" cy="50" r="50" fill="red">
  </circle>
  <text y=50>
    <tspan id="my-text" x=50 text-anchor="middle">Old Text</tspan>
  </text>
</svg>

我有一个 Javascript 函数,当调用它时,将 &lt;tspan&gt; 中的文本更新为“新文本”。此功能在除 IE/Edge 之外的所有浏览器中都能正常工作。

为什么会发生这种情况,我可以做些什么来解决它?谢谢。

【问题讨论】:

    标签: html internet-explorer svg microsoft-edge


    【解决方案1】:

    这个问题回答了我的问题:Updating SVG text using jQuery in IE9-11

    $('#my-text').prop('textContent','New Text'); 在使用 JQuery 时是正确的做法。

    【讨论】:

    • 我会更好地投票关闭它,因为它是重复的,不是吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-29
    • 2023-03-24
    • 2017-09-03
    • 2018-10-19
    • 2018-08-24
    • 2013-08-30
    相关资源
    最近更新 更多