Reputation: 465
I want to change height and width of an svg object on a button click. I tried it but it doesn't work:
function modify() {
document.getElementById('circle1').style.height = "10px";
document.getElementById('circle1').style.width = "10px";
}
Upvotes: 29
Views: 48109
Reputation: 123985
In SVG width and height of <rect>
elements are attributes and not CSS properties so you'd need to write
document.getElementById('cercle1').setAttribute("height", "10px");
similarly for the width.
Upvotes: 62