I need to create this structure using only javascript:
<svg> <use xmlns:xlink="http://www.w3.org/1999/xlink" xlink:href="#circle"></use> </svg> But I have trouble with creating xmlns:xlink attribute. Here is my js code:
var svg = document.createElementNS('http://www.w3.org/2000/svg', 'svg'); var use = document.createElementNS('http://www.w3.org/2000/svg', 'use'); // throws error here use.setAttributeNS('http://www.w3.org/2000/xmlns', 'xmlns:xlink', 'http://www.w3.org/1999/xlink'); use.setAttributeNS('http://www.w3.org/1999/xlink', 'xlink:href', '#circle'); svg.appendChild(use); If I comment string with settings xmlns:xlink all working good and makes svg same as above, but without xmlns:xlink.
I seen a lot of question similar to mine, but they didn't solve my problem.
xmlns:xlinkattribute?