element.attr(attrs)
Set SVG attributes (and JointJS special attributes) on subelements. attr
can either be an object or string representing a path to a nested attribute. If it is an object, the keys of the attrs
object are CSS selectors matching the subelements. The values are objects containing SVG attributes and their values. attrs
object will be mixined with attrs
property of the element
model. This is a convenient way of rewriting only some of the attributes of the subelements. For overwritting all attributes of all subelements, use element.set(attrs)
.
element.attr({
rect: { fill: 'blue' },
text: { fill: 'white', 'font-size': 15 },
'.myrect2': { fill: 'red' }
});
An alternative call using a string path and a value:
element.attr('text/font-size', 12);