d3: how to select a node by text content?

I don’t believe that arrow functions bind this. Try a function function:

d3.select(test).selectAll('g.test-class > text').filter(function() {
  return d3.select(this).text() === "second node"
}).attr('fill', 'red')
1 Like