ToggleSlide 同一类的 2 个实例 - Slide 可以工作,但只有 1 个隐藏
我的 html 中有 2 个同一类 (.attributes) 的实例。我只是想让它们同时切换。第一个实例按预期工作,但第二个实例继续切换打开(样式保持显示:块)。
两个位置中的相关 HTML
<div class="attributes">
content to hide
</div>
jQuery
$(document).ready(function(){
$('.attributes').hide();
$('a#toggle-attributes').click(function() {
$('.attributes').slideToggle(1000);
return false;
});
});
我通过给它一个不同的名称来将“工作”类从图片中删除,但我得到了相同的结果。类中有一个无序列表和一个 div,不会切换到隐藏状态。
任何帮助将不胜感激。 谢谢!
I have 2 instances of the same class (.attributes) in my html. I simply want them both to toggle at the same time. The first instance works as expected, but the 2nd instance continues to Toggle open (style remains display:block).
Relevant HTML in both locations
<div class="attributes">
content to hide
</div>
jQuery
$(document).ready(function(){
$('.attributes').hide();
$('a#toggle-attributes').click(function() {
$('.attributes').slideToggle(1000);
return false;
});
});
I've taken the "working" class out of the picture by giving it a different name but I get the same results. There is an unordered list along with a div in the class that won't toggle to hidden.
Any help would be appreciated.
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我尝试在本地关注。
它按预期工作。
I tried following on my local.
It worked as expected.
好的 - 所以设置正确。我应该寻找什么来阻止第二个个体隐藏?正如我所说,它最初会拉动 .hide() ,并会产生切换幻灯片效果,但它永远不会重新隐藏。任何建议将不胜感激。
更多信息:此代码正在新的 Pinnacle 购物车商店中使用。我隐藏产品页面上的属性(具有许多选择的表单)区域(这是按预期切换),并且还在不同的列中隐藏其他图像。我将更改包装内容的格式(简单文本与当前存在的内容),并报告这是否有效以及我的发现。以前就应该想到这一点,但我对 jQuery 仍然很陌生。
谢谢。
OK - so this is set up correctly. What should I look for that could be stopping the 2nd instance from hiding? As I said, it will pull the .hide() originally, and will do the toggleslide effect, but it never re-hides. Any suggestions would be appreciated.
More info: This code is being used in a new Pinnacle cart store. I'm hiding the attributes (form with many selects) area on a product page (this is toggling as expected) and also hiding additional images in a different column. I'll change the format of what is wrapped (simple text vs what is currently there) and report back if this works and my findings. Should have thought of this previously, but am still pretty new to jQuery.
Thanks.