jquery's append not working with svg element?

后端 未结 14 2217
北海茫月
北海茫月 2020-11-21 06:28

Assuming this:



 
 

        
14条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-21 07:06

    I would suggest it might be better to use ajax and load the svg element from another page.

    $('.container').load(href + ' .svg_element');
    

    Where href is the location of the page with the svg. This way you can avoid any jittery effects that might occur from replacing the html content. Also, don't forget to unwrap the svg after it's loaded:

    $('.svg_element').unwrap();
    

提交回复
热议问题