jquery's append not working with svg element?

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

Assuming this:



 
 

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

    Based on @chris-dolphin 's answer but using helper function:

    // Creates svg element, returned as jQuery object
    function $s(elem) {
      return $(document.createElementNS('http://www.w3.org/2000/svg', elem));
    }
    
    var $svg = $s("svg");
    var $circle = $s("circle").attr({...});
    $svg.append($circle);
    

提交回复
热议问题