我正在尝试动态替换嵌入式 svg 中的图像,我可以获得当前的 href 属性,但将其设置为新属性不会改变任何内容。这甚至可以工作吗,因为它不是通常的 html img 标签?这里有一个(简化为要点)代码摘录:<script> alert(document.getElementById("image1").getAttribute('href')); // this works but document.getElementById("image1").setAttribute('href')='newimage.jpg'; doesn´t do anything</script><svg> <image id="image1" href="test.jpg"></image></svg>
添加回答
举报
0/150
提交
取消