javascript - JQuery: use element's html() (innerHTML) as a parameter to canvas's drawSvg method -



javascript - JQuery: use element's html() (innerHTML) as a parameter to canvas's drawSvg method -

i trying convert/ set svg canvas using drawsvg() function. command is: ctx.drawsvg(svg_xml_or_path_to_svg, dx, dy, dw, dh);. works fine when set svg in parameter, example: ctx.drawsvg('<svg><rect x="0" y="0" width="100" height="100" fill="red" /></svg>', 0 , 0 , 500, 500);, end canvas has reddish square in it, correct. however, need able take svg tag document , utilize parameter. i've tried few different methods none of them work. how can it? here jsfiddle page trying do. thanks! http://jsfiddle.net/qdmhv/722/

.html() returns element's innerhtml including leading , trailing whitespace, drawsvg() chokes on.

try (from fiddle):

ctx.drawsvg($.trim($("#test2").html()), 0 , 0 , 500, 500);

$.trim remove whitespace you.

javascript jquery html svg canvg

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -