我正在嘗試動態替換嵌入式 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>
如何替換嵌入式 svg 中的圖像?
慕斯709654
2022-11-03 15:10:51