+ 8
How can I Change the color of an SVG element, through JS??
In an Svg element like the one given below, How can we select the fill portion, and change it in case of An Event, such as onclick?? <svg xmlns="http://www.w3.org/2000/svg" x="0px" y="0px" width="32" height="32" viewBox="0 0 172 172" style=" fill:#ff22ff;"><g fill="#404040" fill-rule="nonzero" stroke="none" stroke-width="1" stroke-linecap="butt" stroke-linejoin="miter" stroke-miterlimit="10" stroke-dasharray="" stroke-dashoffset="0" font-family="none" font-weight="none" font-size="none" text-anchor="none" style="mix-blend-mode: normal"><path d="M0,172v-172h172v172z" fill="none"></path><path d="..."
2 odpowiedzi
+ 3
element.style.attribute
https://code.sololearn.com/WTrasBlX7j6o/?ref=app
+ 2
You may find answer in https://codepen.io/sdnorm/pen/aOXave, and in https://stackoverflow.com/questions/9872947/changing-svg-image-color-with-javascript.