How do I use javascript to clone an SVG element?

前端 未结 3 593
孤街浪徒
孤街浪徒 2020-12-31 20:11

I am trying to follow the example here under the cloneNode section (fourth occurrence of \'cloneNode\' in the document). The document says it\'s a DRAFT so i\'m wondering i

3条回答
  •  旧时难觅i
    2020-12-31 20:56

    This seems to be more complicated than need be. Start with just your pawn path in your root svg. Then clone, and append to root. One of the important things to address that once you clone, you should change the id of the cloned element. Otherwise you will get a conflict when addressing the original cloned element.

    Try This:

    
        
            
            Title
            
            
            
                

    SVG Source:

    Javascript:

提交回复
热议问题