//通过点击记住某一元素的显示或隐藏状态,只记住需要显示的元素ID
function showmore(id) {
if ( $("#"+id).css('display') == "none" ){
$("#"+id).show();
var showids = JSON.parse(localStorage.getItem("showids") ) ? JSON.parse(localStorage.getItem("showids") ) :[] ;
if(showids ){
const index = showids.indexOf(id);
if(index == -1){
showids.push(id);
localStorage.setItem("showids",JSON.stringify(showids));
}
} else{
showids.push(id);
localStorage.setItem("showids",JSON.stringify(showids));
}
}else{
$("#"+id).hide();
var showids = JSON.parse(localStorage.getItem("showids") ) ? JSON.parse(localStorage.getItem("showids") ) :[] ;
if(showids ){
const index = showids.indexOf(id);
if(index != -1){
showids.splice(index, 1);
localStorage.setItem("showids",JSON.stringify(showids));
}
}
}
}
//初始化显示某元素的显示状态
var showids = JSON.parse(localStorage.getItem("showids") ) ? JSON.parse(localStorage.getItem("showids") ) :[] ;
if(showids){
for (var i = showids.length - 1; i >= 0; i--) {
$("#"+showids[i]).show();
}
}