查询类切换以更改跨度背景图像不起作用
好吧,我对 jQuery 有足够的了解,可以完成我的一些任务(显然除了这个)。
情况:
我有一个手风琴菜单,其中有加号和减号图像,显示在菜单的左侧。我希望它们在子表可见时改变。
我的代码中有一些错误不允许这种情况发生。当您单击其中一个选项时,它将变为减号;当您单击另一个选项时,它将变为加号。
问题: 扩展区域后,如果再次单击可见选项来折叠元素,手风琴类将不会更改。
这是一个 jsfiddle 演示 http://jsfiddle.net/mKUNs/
Ok, I know enough about jQuery to get some of my tasks accomplished (well except this one apparently).
The situation:
I have an accordion menu that has plus and minus images that are shown in the left hand side of the menu. I want them to change when the child table is visible.
there is some bug in my code that won't allow this to happen. it will change to the minus when you click one of the options and it will change to the plus when you click another option.
The Problem:
Once an area is expanded the accordion class won't change if you click the visible option again to collapse the element.
Here is a jsfiddle demo
http://jsfiddle.net/mKUNs/
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是一个固定版本。 但不要使用它。
您的文档结构非常糟糕。您的表格只有一个单元格,标题和可切换部分之间的关联仅通过相邻关系进行。您最好更改标记,以便每个手风琴都被
/
包围。
此外,您已经不再使用
id
,并且您的 CSS 都应该从文档中删除。不应使用align="center"
。最后,为什么要为expand
ed 和collapse
d 建立一个类来搞乱事情呢?两者是互斥的,所以只使用一个类!你应该这样做:
HTML
CSS:
jQuery
Here's a fixed version. But don't use it.
Your document is structured very badly. You've got tables with only one cell, and association between the header and the toggleable section is only by adjacency. You'd do better to change your markup so that each accordian is surrounded by a
<div>
/<section>
.Additionally, you're over using
id
s, and your CSS should all be taken out of the document.align="center"
should not be used. Lastly, why muddle things by having a class forexpand
ed andcollapse
d? The two are mutually exclusive, so just use one class!This is how you should do it:
HTML
CSS:
jQuery