How to use jquery in SVG (Scalable Vector Graphics)?

前端 未结 2 716
孤街浪徒
孤街浪徒 2020-12-02 11:12

I have embedded SVG in my php file to show a map. I want to use jquery on It but I have no idea on how to link jquery in it. I hope someone has already done such thing. So p

2条回答
  •  醉梦人生
    2020-12-02 11:54

    SVG uses elements in the DOM ie.

    
        My SVG
        
           
    
    

    Accessing it and manipulating it can be done the same way jQuery manipulates any other Object in the DOM. ie.

    $('svg path').remove(); //removes the path.
    

    If you are looking for a javascript library to manipulate SVG elements, check out Raphael.js.

提交回复
热议问题