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 attributes of the groups I've made inside the SVG by toggling the classes of the different groups.
I'm trying to use JQuery's toggleClass()
but it is not working. I would like to bind the changes on the class to some click events on <span>
elements on the sidebar.
Does Jquery not work with SVG?
相关问题
- How to fix IE ClearType + jQuery opacity problem i
- jQuery add and remove delay
- Include empty value fields in jQuery .serialize()
- Disable Browser onUnload on certain links?
- how to get selected text from iframe with javascri
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
usingsetAttribute()
:Or use one of the various JS support libraries for SVG manipulation.