05-01-2019 15:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-01-2019 15:17
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi guys
I am having this weird issue with my code. What I want to do is to use DOM in order to change the fill color of a circle in SVG. However, the thing is that the circle's color doesn't change and stays the color I created it as. What's even more strange is that to debug I logged the fill color of the circle after the color change. I saw that the circle's fill color accessed via DOM was the color I wanted it to be, but the color change wasn't shown on the watch display. Here is my SVG code:
<circle cx="50%" cy="50%" r="20" fill="black" id="foo" />
and here is my JS code:
import document from "document"; var someCircle = document.getElementById("foo"); someCircle.fill = "#00FF00;
Can anyone tell me why this isn't working, and how to fix it? Thanks!
Answered! Go to the Best Answer.

Accepted Solutions
05-01-2019 15:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-01-2019 15:19
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-01-2019 15:19
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Hi guys
I am having this weird issue with my code. What I want to do is to use DOM in order to change the fill color of a circle in SVG. However, the thing is that the circle's color doesn't change and stays the color I created it as. What's even more strange is that to debug I logged the fill color of the circle after the color change. I saw that the circle's fill color accessed via DOM was the color I wanted it to be, but the color change wasn't shown on the watch display. Here is my SVG code:
<circle cx="50%" cy="50%" r="20" fill="black" id="foo" />
and here is my JS code:
import document from "document"; var someCircle = document.getElementById("foo"); someCircle.fill = "#00FF00;
Can anyone tell me why this isn't working, and how to fix it? Thanks!

05-01-2019 15:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-01-2019 15:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
Untested:
someCircle.style.fill
Gondwana Software

05-01-2019 17:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post

05-01-2019 17:20
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
- Who Voted for this post?
05-01-2019 17:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post


05-01-2019 17:33
- Mark as New
- Bookmark
- Subscribe
- Permalink
- Report this post
*phew*
Gondwana Software

