Ano-Tech Computers
Enter keyword:

SVG+Javascript: Get or set element properties
Problem:
How do I access the current SVG element properties, and how do I change them?
 
Solution:
Access the current value of a circle element (assuming 'object' references the circle):
posx = object.cx.baseVal.value;

Change the value of a that same element:
object.style.setProperty('cx', posx, '');

 
Discuss this solution
Did this article solve your problem? Yes No Did not apply

We welcome anyone who is willing to contribute to this public knowledge base, contact siteadmin@atc.no if you have information you would like to share. The idea is not to replace the commercial support sites, but to publish those hard-to-find solutions you've found yourself looking for over and over again.

Show all articles