我正在嘗試動態(tài)替換嵌入式 svg 中的圖像,我可以獲得當(dāng)前的 href 屬性,但將其設(shè)置為新屬性不會改變?nèi)魏蝺?nèi)容。這甚至可以工作嗎,因為它不是通常的 html img 標(biāo)簽?這里有一個(簡化為要點)代碼摘錄:<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