javascript - Element created with createElementNS doesn't show -


i'm trying create new <img> <svg> tag javascript every time click on button. when see result in console firebug works correctly, nothing on screen displays. want image <svg> appear after last 1 every time click button.

thanks in advance.

    var svgns = "http://www.w3.org/2000/svg";   mybtn.addeventlistener("click", createcirclesvg);       function createcirclesvg(){       var d = document.createelement('svg');       d.setattribute('id','mysvg');        document.getelementbyid("svgcontainer").appendchild(d);        createcircle();     }      function createcircle(){          var mycircle = document.createelementns(svgns,"circle"); //to create circle."         mycircle.setattributens(null,"id","mycircle" + opcounter++);         mycircle.setattributens(null,"cx",25);         mycircle.setattributens(null,"cy",25);         mycircle.setattributens(null,"r",100);         mycircle.setattributens(null,"fill","black");         mycircle.setattributens(null,"stroke","blue");          document.getelementbyid("mysvg").appendchild(mycircle);     }   

create svg:

var svg = document.createelementns(ns, 'svg'); 

first function:

function createsvg() { ... } 

second function:

function createsvgcircle() { createsvg() ... } 

or separated:

createsvg(); createsvgcircle(); 

example


Comments

Popular posts from this blog

node.js - Using Node without global install -

How to access a php class file from PHPFox framework into javascript code written in simple HTML file? -

java - Null response to php query in android, even though php works properly -