1

I want to select and remove a textPath from a SVG where xlink:href=id. A textPath has an attribute xlink:href and I have a variable called 'id'.

I want to remove textPath that has xlink:href equal to the value stored in variable id.

Something like this:

d3.select("textPath*some condition*").remove();

Can this be done? If yes, how?

Robert Longson
  • 118,664
  • 26
  • 252
  • 242
Arihant
  • 3,847
  • 16
  • 55
  • 86

2 Answers2

4

You need to need to use some trickery due so querySelector namespace limitations

d3.select(('[*|href="#id"]')
Community
  • 1
  • 1
methodofaction
  • 70,885
  • 21
  • 151
  • 164
-2

Can't you just build it with string addition? Something like:

var selector = "xlink:href=" + id
d3.select(selector).remove()
reptilicus
  • 10,290
  • 6
  • 55
  • 79