【发布时间】:2013-07-11 08:57:54
【问题描述】:
您好,我目前在我的网站上使用下面的代码作为可展开的页脚。
我想对其进行调整,以便在单击链接类“.toggle”时,它将向元素添加一个名为“.is-open”的类,到目前为止,代码会执行此操作,但另外我想要代码将“.is-open”类添加到另一个名为“.footercontrol”的类中
$(".footer, .toggle:not(:first-child)").hide();
$(".toggle").click(function(e) {
e.preventDefault();
if ( $(this).hasClass("is-open") ){
$(this).removeClass("is-open").nextAll(".footer, .toggle:not(:first- child)").slideUp(500).removeClass("is-open");
return;
}
$(this).toggleClass("is-open");
$(this).next(".footer").slideToggle(500).next(".toggle").slideToggle(500);
$("html, body").animate({
scrollTop: $(document).height()
}, 500);
});
提前致谢:)
【问题讨论】:
标签: jquery class onclick footer