Appending child | Sololearn: Learn to code for FREE!

+1

Appending child

Why can't I append "line" to "svg"? https://code.sololearn.com/WEwrgyrjOQS6/?ref=app

10/6/2017 2:34:31 PM

Tom2003611

4 Answers

New Answer

+4

To manipulate SVG commands on JavaScript, one must use the svg <script> element

+4

svg uses a namespace. Use document.createElementNS(): https://stackoverflow.com/a/16489845 I use it in [JS] line 80 here: https://code.sololearn.com/WKLubPzanpv8/?ref=app

+4

Try this instead var line = document.createElementNS("http://www.w3.org/2000/svg", 'line');

+3

You can! Just that it's an object, thus that display