如何切换下拉箭头
这是我用来隐藏和显示具有滑动切换效果的 div 的代码。
jQuery(document).ready(function() {
jQuery(".option-content").hide();
jQuery(".option-heading").click(function()
{
jQuery(this).next(".option-content").slideToggle(500);
});
});
不过,我想添加一些切换箭头来显示切换的 div 向上或向下。
这是我到目前为止所拥有的,它做了我想要做的一半:
jQuery(document).ready(function() {
jQuery(".option-content").hide();
jQuery("#arrow-up").hide();
jQuery(".option-heading").click(function()
{
jQuery(this).next(".option-content").slideToggle(500);
jQuery("#arrow-up").toggle();
jQuery("#arrow-down").toggle();
});
});
这会切换箭头,但有两个问题:
- 向下箭头保持显示
- 每个div都会切换每个箭头,因此当一些div向上而一个向下时它们都显示为向下。
任何想法都会被采纳
This is the code i am using to hide and display div's with a slide toggle effect.
jQuery(document).ready(function() {
jQuery(".option-content").hide();
jQuery(".option-heading").click(function()
{
jQuery(this).next(".option-content").slideToggle(500);
});
});
However i would like to add some toggled arrows to show that the toggled div is up or down.
This is what i have so far and it does half of what i would like it to do:
jQuery(document).ready(function() {
jQuery(".option-content").hide();
jQuery("#arrow-up").hide();
jQuery(".option-heading").click(function()
{
jQuery(this).next(".option-content").slideToggle(500);
jQuery("#arrow-up").toggle();
jQuery("#arrow-down").toggle();
});
});
This toggles the arrow but there are two problems:
- The down arrow stays shown
- Every div toggles every arrow so when some divs are up and one is down they all show as down.
Any ideas would be appriciated
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
:before
伪值来装饰箭头图标.toggleClass()
PS:如果您使用一些不同的字体图标(例如 ie:icomoon),请将相应的十六进制代码以及
font-family: 'icomoon';
添加到:before伪。
:before
pseudo for decorative arrow icons.toggleClass()
P.S: If you're using some different font-icons (like i.e: icomoon) than add the respective hex codes and also
font-family: 'icomoon';
to the:before
pseudo.使用类!
然后使用CSS:
Use classes!
Then use CSS: