jquery's append not working with svg element?

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

Assuming this:



 
 

        
14条回答
  •  清酒与你
    2020-11-21 06:47

    The accepted answer by Bobince is a short, portable solution. If you need to not only append SVG but also manipulate it, you could try the JavaScript library "Pablo" (I wrote it). It will feel familiar to jQuery users.

    Your code example would then look like:

    $(document).ready(function(){
        Pablo("svg").append('');
    });
    

    You can also create SVG elements on the fly, without specifying markup:

    var circle = Pablo.circle({
        cx:100,
        cy:50,
        r:40
    }).appendTo('svg');
    

提交回复
热议问题