In the following example, I attempt to dynamically add a link tag to an svg element.
http://lizziemalcolm.com/svgtest.html
$('#button').click(function(){
$('.svgClass').wrap('<a xlink:href="http://www.w3.org/" />');
});
In the example, although the syntax is exactly the same, the ellipse with the dynamically added link dissapears.
Any ideas why this might be happening?
The reason I am attempting this, is I wish to have make custom http://www.addthis.com/ icons using SVG, and the element must be enclosed in an tag.
Also tried with pure javascript but no luck:
function wrapElem( innerId, wrapType, wrapperId, wrapperUrl ){
var innerElem = document.getElementById( innerId ),
wrapper = document.createElement( wrapType );
wrapper.appendChild( innerElem.parentNode.replaceChild( wrapper, innerElem ) );
wrapper.setAttribute('xml:id', wrapperId);
wrapper.setAttribute('xlink:href', wrapperUrl);
return wrapper;
}
link is also updated