I have an array with <SVG>
element code. How can I append to that using JavaScript. I tried the following:
Example Array:
global_array[0] = [ '<svg data="BusinessProductFigure" x="553.671875"
y="167" id= "something" xmlns="http://www.w3.org/2000/svg"
version="1.1"><rect x="4" y="4" width="60" height="14"
fill="rgb(299,299,162)" stroke-linejoin="round"
stroke="rgb(299,299,162)" stroke-width="1"/></svg>' ]
Appending [1]
for(var i = 0; i <= global_array.length; i++) {
document.getElementById("main_svg").innerHTML = global_array[i];
}
})
Gives no error but nothing is appended. Checked in console.
Appending test [2]
for(var i = 0; i <= global_array.length; i++) {
d3.select("#main_svg").append(global_array[i]);
}
})
This gives DOM Exception error.