Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

outerHtml returns undefined for SVG elements in IE

Here is my code

<svg id="a" height="210" width="400">
  <path id="b" d="M150 0 L75 200 L225 200 Z" />
</svg>

i have trigger mouse move event on b

   $("#b").hover(function() {
        alert($(this)[0].outerHTML);
    });

this was working in chrome but not working in IE how can i solve this..

please find the JSFiddle link : http://jsfiddle.net/r8v70Lnk/

alert box will show only in chrome but not in IE..

like image 710
Akbar Basha Avatar asked Apr 27 '15 05:04

Akbar Basha


1 Answers

Dont know if it is a solution for you but i usually do it like:

new XMLSerializer().serializeToString(document.querySelector('#b'))

If you want to parse the string again and insert the node in your document:

new DOMParser().parseFromString(svgString, "image/svg+xml")
like image 66
Philipp Wrann Avatar answered Sep 22 '22 15:09

Philipp Wrann