Get SVG representation of div using jQuery SVG

独自空忆成欢 提交于 2019-12-25 18:32:28

问题


I am trying to get svg representation of a div.I am using jQuery SVG for this http://keith-wood.name/svg.html

I am doing this on page load:

var pad = null;
    $('.MyDiv').svg({onLoad: function(svg) { 
        pad = svg; 
    } 
    });

and on every change inside div , i am doing this:

var svg = $('.MyDiv').svg('get'); 
alert(svg.text);

but i am getting some JS code in alert. i tried alerting svg.toSVG() but i am getting this :

<svg version='1.1'></svg> in alert

svg.toSVG() seems to work but i am getting empty svg doc even if my div has data in it.

what i am doing wrong here?


回答1:


The innerSVG shim might be helpful to you.



来源:https://stackoverflow.com/questions/11340476/get-svg-representation-of-div-using-jquery-svg

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