Chris
Chris

Reputation: 3405

Recolorable SVG icons in a web page?

I'm writing a quite complicated, big and long living (it might display for many days) web page that will also need icons. These icons are supposed to be SVG graphics. Depending on the place on the page the SVG should be recolored by JavaScript calls (jQuery or even jQuery-SVG is fine).

So my questions are:

Required browsers are the usual compliant modern ones (Firefox, Chrome, Opera, Safari) for normal PC as well as mobile (Android, iOS). Internet Explorer compatability is not required.

Upvotes: 1

Views: 541

Answers (1)

Robert Longson
Robert Longson

Reputation: 123995

If you want to recolour it then <img> is out straight away as you can't change images with javascript either externally or internally.

If you put clone data then you'll need to make sure that any id attributes remain unique within a single document so perhaps having things as <object> would be easiest for you.

You can use straight DOM calls to change the colour of things in an SVG graphic or you can use jquery if you want.

For the rest you'll probably have to try things and see how they work out for you.

Upvotes: 1

Related Questions