1

Given an svg with an existing id="kvg:StrokeNumbers_07425",

<g id="kvg:StrokeNumbers_07425" style="font-size:8;fill:blue;">...</g>

I do the following :

d3.select("#kvg:StrokeNumbers_07425").attr("style","fill:red;");

and get the following error message :

Uncaught SyntaxError: Failed to execute 'querySelector' on 'Document': 
'#kvg:StrokeNumbers_07425' is not a valid selector.

It's likely due to the :.

What should I do to make it work?


EDIT: http://jsfiddle.net/0v7jjpdd/1/

Hugolpz
  • 17,296
  • 26
  • 100
  • 187

1 Answers1

4

Escape the : as such

d3.select("#kvg\\:StrokeNumbers_07425").attr("style","fill:red;");

JSFiddle Link

scniro
  • 16,844
  • 8
  • 62
  • 106