I’d like to wrap a series of <g>
elements with <a>
elements so they are tabbable. I've tried using jQuery but encountered the namespace problem so have been looking at a more vanilla JS approach. The SVG was created in Illustrator and loaded into the page with an AJAX call. I then use jQuery to bind events etc. I know I can add them in Illustrator with Image Map but I’d like to find a way to get it done programmatically. This is what I’d like to do:
$('g').wrap(function() {
var anchor = document.createElementNS('http://www.w3.org/2000/svg', 'a');
anchor.setAttribute('xlink:href', 'javascript:void(0);');
return anchor;
});
This gets it into the DOM but doesn't render so I'm assuming a namespace problem still. I’m more than likely doing something obviously wrong so any help would be greatly appreciated! Thanks.
Here's a pure JS fiddle (same problem as code above): http://jsfiddle.net/bigwigal/pqe3o93e/.