TAG
CSS
JavaScript
Result
Run
License
<img id="mysvg" src="/assist/resources/svgs/character.svg" /> <button type="button" id="btn-transform">Transform</button>
#mysvg { width: 50vmin; } /* Can't handle CSS externally */ .tail-custom { stroke: #FF0000 !important; }
window.addEventListener("load", () => { const elBtnTransform = document.getElementById("btn-transform"); const elSVGObj = document.getElementById("mysvg"); elSVGContent = elSVGObj.contentDocument; const elTailPath = elSVGContent.querySelector(".tail-custom"); elBtnTransform.onclick = e => { elTailPath.setAttribute("transform-origin", "155 168"); elTailPath.setAttribute("transform", "rotate(45)"); }; });
Console
expand_less
License
License
by DevDic
Close