使用 .slidetoggle 使 div 在页面加载时再次展开和折叠
大家好,我有一个带有文本的 div 框,它是隐藏的,直到您单击按钮,然后它 .slideToggles 打开到其高度,然后当您再次单击时它会切换关闭。
现在我想做的是在页面加载时让框展开,然后再次折叠并停止(不是自动重复),以便人们看到隐藏的内容并单击按钮。有人可以帮忙吗?我不太喜欢 jQuery。
这就是我所拥有的。
$(document).ready(function() {
$("#page-information").hide();
$(".info-tab").toggle(function() {
$(".info-tab").addClass("info-active");
}, function () {
$(this).removeClass("info-active");
});
$(".info-tab").click(function() {
$("#page-information").slideToggle('slow');
});
});
任何帮助将不胜感激。我以为你可以在一开始就连续进行两次滑动切换,但显然不行。
谢谢你们。
Hi guys i have a div box with text which is hidden until you click a button and then it .slideToggles open to its height and then when you click again it toggles closed.
Now what i would like to do is on page load for the box to expand and then collapse again and stop (not auto repeat ), so that people see that there is content hidden away and to click the button. Can anyone help with this?? I'm not big into jQuery.
Here's what i've got.
$(document).ready(function() {
$("#page-information").hide();
$(".info-tab").toggle(function() {
$(".info-tab").addClass("info-active");
}, function () {
$(this).removeClass("info-active");
});
$(".info-tab").click(function() {
$("#page-information").slideToggle('slow');
});
});
Any help would be greatly appreciated. I thought you could just do two slidetoggles back to back at the beginning but obvioulsy not.
Thanks guys.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试一下:
它的工作示例: http://jsfiddle.net/ufomammut66/yRqqq/2/
Give this a go:
Example of it working: http://jsfiddle.net/ufomammut66/yRqqq/2/
也许是这个?
Maybe this?