d3 .attr method code example
Example 1: d3.select specific div
//Class
d3.select(“.classname”)
//Unique identifier
d3.select(“#line”)
//Attribute
d3.select(“[color=black]”)
Example 2: html tag convert to d3.select() point
var selection = d3.select(domElement);
// later via the selection you can retrieve the element with .node()
var elt = selection.node();
Example 3: d3 property vs attr
<input type="checkbox" checked=true/>
$('input').prop('checked'); // returns true
$('input').attr('checked'); // returns "checked"