score:1

Accepted answer

You have several options here.

d3.selectAll("links") will select all links elements in the SVG. That obviously won't work, since there is no <links> element in the SVG specs.

Therefore, one solution is selecting the lines:

d3.selectAll("line")

Another one, in case you have other lines in the SVG, is using the selection:

linksRef.selectAll("line")

Finally, you can just set a class...

var linksRef = svgRef.append("g")
    .attr("class", "links")
    .selectAll("line")
    .data(links_data).enter()
    .append("line")
    .attr("class", "link")

... and select by that class:

d3.selectAll(".link")

Related Query

More Query from same tag