I've been able to achieve certain success with the following code to target id attributes using JavaScript to set multiple attributes:
function setAttributes(el, attrs) {
for(var key in attrs) {
el.setAttribute(key, attrs[key]);
}
}
setAttributes(svgShape,{'d':complexShape,'fill':'#f04'});
However, would it be possible to use that code or a similar code to target class attributes, not id attributes?