0

I need to append elements that are in string into svg.I used the below code to do this.

 var namespaceURI = "http://www.w3.org/2000/svg";
 var svg = document.createElementNS(namespaceURI, "svg");
 svg.setAttributeNS("http://www.w3.org/2000/xmlns/", "xmlns:xlink", "http://www.w3.org/1999/xlink");
 $(svg).append('<path d="M10,20 L20,30" fill="pink" stroke="gray"></path>');

But it is created as html element and nothing is on screen.In jquery we usually do like $( "p" ).append( "<strong>Hello</strong>" ) to append elements.

I referred this link too. But I dont want to create new element using document.createElementNS(..).Instead I need to append element specified in string.

Is there any options to do this??

Community
  • 1
  • 1
Swarna Latha
  • 1,004
  • 12
  • 21
  • "I dont want to create new element using document.createElementNS" With what reason? That is the way to go, as the DOM classes do not know per default, which namespace you are using currently… – feeela May 12 '14 at 13:57
  • This question may help: http://stackoverflow.com/questions/9723422/is-there-some-innerhtml-replacement-in-svg-xml – Paul LeBeau May 12 '14 at 14:01

0 Answers0