const secondLink = d3.selectAll('a:nth-child(2)'); console.log(secondLink.attr('href')); // 1 arg: getter, 2 args: setter secondLink.attr('href', 'http://google.com'); console.log(secondLink.attr('href')); d3.selectAll('a:nth-child(2)') // 1 arg: getter, 2 args: setter .style('color', 'green'); const thirdLink = d3.selectAll('a:nth-child(3)') // attr(elem, val) returns the selection on which it has been called .attr('href', 'http://bing.com') // Usually, use CSS rather than inline styles. // 1 arg: getter, 2 args: setter .style('color', 'orange'); console.log(thirdLink.attr('href')); const firstChild = d3.selectAll('a:nth-child(1)') // Can't use "class" as it's a JS keyword. .classed('red', true); console.log(firstChild.attr('class')); // 0 arg: getter, 1 args: setter d3.select('a.action') .text('Inventory'); d3.select('a') .html('About SALE')