Why .html() doesn't work with SVG selectors using jquery ?

南楼画角 提交于 2019-11-30 06:54:26

As far as I can recall jQuery's .html() makes use of innerHTML which is meant for html, not svg. SVG's are xml documents, so you can use XMLSerializer()

var svg = document.getElementById('svg_root'); // or whatever you call it
var serializer = new XMLSerializer();
var str = serializer.serializeToString(svg);
Guest

For the problem you are not getting your svg content,
If only one svg chart is on page then use:

$('svg').html();

and if more than present then please see there is a div of highcharts_container because they create that svg charts. If you are using them.
Then use:

$('id of that div').html();
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!