Why can not we get outerHTML of an svg element with element.outerHTML property?
Is this way is the best http://jsfiddle.net/33g8g/ for getting svg sourc
SVGElements don't have outerHTML property.
You can define like this in pure Javascript
Object.defineProperty(SVGElement.prototype, 'outerHTML', {
get: function () {
var $node, $temp;
$temp = document.createElement('div');
$node = this.cloneNode(true);
$temp.appendChild($node);
return $temp.innerHTML;
},
enumerable: false,
configurable: true
});
Or a one line jQuery solution would be
$('').append($(svgElement).clone()).html();
Reference:
https://gist.github.com/jarek-foksa/2648095