独立滑动切换链接
一直试图让 SlideToggle 在已打开的情况下关闭,或者在已打开的情况下不重新打开。查遍了这个功能,但没有结果。任何帮助将不胜感激!
jQuery
<script>
$(document).ready(function() {
$(".shareLink").click(function(){
$(".hideShare").hide();
$("#"+$(this).attr('id')+'Box').slideToggle();
return false;
});
});
</script>
这里有一个链接 http://digitalzu.net/jquery.html
Been trying to get slideToggle to close if already opened aka not reopen if already open. Searched all over for this function but to no avail. Any help would be much appreciated!
jQuery
<script>
$(document).ready(function() {
$(".shareLink").click(function(){
$(".hideShare").hide();
$("#"+$(this).attr('id')+'Box').slideToggle();
return false;
});
});
</script>
heres a link to it
http://digitalzu.net/jquery.html
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
它不起作用,因为您隐藏了所有
hideShare
元素,其中也包括当前框,因此它只是切换。试试这个,它只会隐藏它的
兄弟
。演示
Its not working because you are hiding all the
hideShare
elements which includes the current box also so it just toggles.Try this, it will only hide its
siblings
.Demo
您隐藏了所有内容,然后向下滑动一个元素。问题是即使该元素已经可见,您也会这样做。相反,请确保它尚未可见,如果可见,则不执行任何操作。
You're hiding everything and then sliding down the one element. The problem is that you are doing this even if the element is already visible. Instead, make sure that it is not already visible, if it is, do nothing.