能否改进,只有单角功能?
var show = $("#shows ul li");
show.addClass("active");
$(show).each(function(c){
var cvalue = $.cookie( show + c);
if ( cvalue == closed + c ) {
$(this).css({display:"none"});
$(this).removeClass( active ).addClass( inactive );
};
});
$("#shows li.active").toggle(function(){
var num = show.index(this);
var cookieName = show + num;
var cookieValue = closed + num;
$(this).slideUp(500);
$(this).removeClass( active );
$.cookie(cookieName, cookieValue, { path: / , expires: 10 });
},function(){
var num = $(this).index(this);
var cookieName = show + num;
$(this).slideDown(500);
$(this).addClass("active");
$.cookie(cookieName, null, { path: / , expires: 10 });
});
$("#shows li.inactive").toggle(function(){
var num = show.index(this);
var cookieName = show + num;
$(this).slideDown(500);
$(this).addClass("active");
$(this).removeClass( inactive );
$.cookie(cookieName, null, { path: / , expires: 10 });
},function(){
var num = show.index(this);
var cookieName = show + num;
var cookieValue = closed + num;
$(this).slideUp(500);
$(this).removeClass( active );
$.cookie(cookieName, cookieValue, { path: / , expires: 10 });
});