Is there a method to apply javascript on sprite.svg file components? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 1

Is there a method to apply javascript on sprite.svg file components?

I have a bundle of SVG components in my sprite.SVG file and an HTML page where I am including those SVG components here in HTML. eg: <svg class="svg-icon"> <use xlink:href="sprite.svg#hiw-svg"></use> </svg> Now, I want to apply javascript on the components of SVG's which I included, So how should I do that since those components are defined in the sprite.SVG file. One possible solution is that I include those sprite symbols directly as SVG in my HTML but I don't want to do that as I have lots of SVG's which will take a lot of space in HTML. So what is the best way I can apply GreenSock js or simply (JS) for animations on the sprite.SVG file.

15th Jul 2021, 8:34 AM
Shubham Pandey
Shubham Pandey - avatar
1 Answer
31st Jul 2021, 10:16 AM
Sancho Godinho
Sancho Godinho - avatar