0
我有这段代码,只要我重新加载或刷新页面,该代码就可以工作,但可以返回到初始关闭状态。即使在页面重新加载之后,我也希望保留最后的切换状态似乎无法解决这个问题。Slidetoggle在页面刷新时保留当前状态
我的代码是:
var $answers = $('.contentbar');
$(".titlebar").click(function() {
var $ans = $(this).next(".contentbar").stop(true).slideToggle(500);
$answers.not($ans).filter(':visible').stop(true).slideUp();
})
使用'localStorage'或'cookie'来保存状态。 – Regent 2014-09-22 12:56:13