问题
I want change height or width when a click in a button. I try this but not work:
function modify(){
document.getElementById('cercle1').style.height = "10px";
document.getElementById('cercle1').style.width = "10px";
}
回答1:
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.
来源:https://stackoverflow.com/questions/26392165/change-height-width-of-object-svg-using-javascript