jquery's append not working with svg element?

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

Assuming this:



 
 

        
14条回答
  •  甜味超标
    2020-11-21 06:57

    The increasingly popular D3 library handles the oddities of appending/manipulating svg very nicely. You may want to consider using it as opposed to the jQuery hacks mentioned here.

    HTML

    
    

    Javascript

    var circle = d3.select("svg").append("circle")
        .attr("r", "10")
        .attr("style", "fill:white;stroke:black;stroke-width:5");
    

提交回复
热议问题