Created
February 12, 2014 13:30
-
-
Save Torthu/8955564 to your computer and use it in GitHub Desktop.
Add textNode to g-element in SVG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // textToDisplay = whatever you want to fill the textnode with | |
| // elementId g element id (that the textnode will be appended to) | |
| function addTextToG(textToDisplay, elementId) { | |
| // create svg text node | |
| var textNode = document.createElementNS("http://www.w3.org/2000/svg","text"); | |
| textNode.appendChild(document.createTextNode(textToDisplay)); | |
| // append created textnodes to g nodes | |
| document.getElementById(elementId).appendChild(textNode); | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment