link.attr(attrs, [, opt])

Set presentation attributes (SVG and JointJS attributes) on subelements. This is a method analogous to attr method of joint.dia.Element. The keys of the attrs object are selectors (JSON Markup Selector or CSS Selector) matching the SVG element the link consists of. The values are objects containing SVG attributes and their values. attrs object will be mixed with attrs property of the link model. This is a convenient way of rewriting only some of the attributes of the SVG elements. For overwriting all attributes of all SVG elements, use link.set('attrs', attrs).

    // selector as defined in JSON markup
    line: {
        stroke: 'red',
        targetMarker: {
            type: 'circle',
            r: 5
element.attr(path, value [, opt])

An alternative call using a string path and a value:

link.attr('line/stroke', 'red');
link.attr(['line', 'targetMarker', 'type'], 'path');

Get attribute value defined by a path. If no path provided the whole attrs object is returned.

var color = link.attr('line/stroke');
var targetMarkerType = link.attr(['line', 'targetMarker', 'type']);