Jquery toggleClass on inline SVG

后端 未结 1 1439
夕颜
夕颜 2021-01-13 19:18

I\'ve got a layout with an inline SVG (an archaeological drawing of a site\'s floor plant) with some explanatory text in a sidebar and I would like to change some of the att

相关标签:
1条回答
  • 2021-01-13 20:07

    No. jQuery is designed to work with HTML. SVG elements are in the SVG namespace and the jQuery functions generally don't work on them.

    You can modify an SVG element's class using setAttribute():

    mysvgelement.setAttribute("class", someclass);
    

    Or use one of the various JS support libraries for SVG manipulation.

    0 讨论(0)
提交回复
热议问题