outerHTML of an SVG element

前端 未结 5 1993
天命终不由人
天命终不由人 2020-12-09 03:46

Why can not we get outerHTML of an svg element with element.outerHTML property?

Is this way is the best http://jsfiddle.net/33g8g/ for getting svg sourc

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-09 03:51

    Using jQuery, you can easily create a temporary HTML wrapper around any element that doesn't support outerHTML :

    function wrappedHtml(elt){
        var wrapped = elt.wrap("").parent().html();
        elt.unwrap();
        return wrapped;
    }
    

提交回复
热议问题