Load external SVG file into variable and append to html

前端 未结 1 1887
孤街浪徒
孤街浪徒 2021-01-14 07:14

I\'m trying to replace an SVG image embedded in IMG tag with the content of this SVG and output it inline. In other words lo load the contents of SVG file of given IMG SRC a

相关标签:
1条回答
  • 2021-01-14 07:28

    You cannot load data via ajax using the file:// protocol. You need to use http://

    For example, move the svg file to the same folder as your javascript file and then do:

    $.get('img01.svg', function(data) {
        $bg.append(data);
    });
    
    0 讨论(0)
提交回复
热议问题