jQuery SVG removeClass() [英] jQuery SVG removeClass()

查看:205
本文介绍了jQuery SVG removeClass()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好几个小时后试图找出一种解决方法,我什么也没想出来.我知道我需要SVG jQuery插件,所以我知道了这一点,并且可以使用toggleClass()函数,但是我试图从所有组元素中删除类,然后也向该组元素中添加另一个类:

Ok after hours and hours trying to figure out a way to do this, I have come up with nothing. I knew that I need the SVG jQuery plugin so I have that and have gotten the toggleClass() function to work, but I'm trying to remove classes from all of my group elements and then add another class to the group elements as well:

$('g').removeClass().addClass('slice');

我从jQuery网站上的removeClass文档中获得了这一行代码.

I came upon this line of code from the removeClass documentation on the jQuery site.

最终,我希望获得此饼图的技能,即单击某个切片时,将其从饼中略微移开,直到单击另一个切片为止.一旦单击另一个切片,则前一个切片将返回到饼图,然后将新单击的切片拉出.通过查看我的jsFiddle,您可以看到我在做什么.我设法将这些切片拉出,但是当我单击另一个切片时,我正在努力使它们滑回.

Ultimately my desire is to have this Pie Chart of skills that when a slice is clicked, it is slightly removed from the pie until another slice is clicked. Once another slice is clicked then the previous slice is returned to the pie and the newly clicked slice is pulled out. You can see what I'm getting at by checking out my jsFiddle. I've managed to get the slices to pull out, but where I'm struggling is getting them to slide back in when another slice is clicked.

jsFiddle示例: http://jsfiddle.net/jrjacobs24/BhWCh/30/

jsFiddle Example: http://jsfiddle.net/jrjacobs24/BhWCh/30/

我一直在尝试浏览Keith Wood的插件的文档:

I've been trying to go throuh the documentation for Keith Wood's plugin here:

http://keith-wood.name/svg.html#dom

但是没有任何运气.任何帮助将不胜感激.让我知道是否有任何疑问或需要澄清.预先谢谢你!

but just haven't had any luck. Any help would be greatly appreciated. Let me know if anything is vague or needs clarity. Thank you in advance!

推荐答案

您最好将.clicked视为.slice元素的状态/类. 无需删除.slice类.

You should better consider .clicked as a state/class for your .slice elements. There is no need to remove .slice class.

看看这个小提琴: http://jsfiddle.net/sinsedrix/AKXTV/

这篇关于jQuery SVG removeClass()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆