Javascript jQuery在列表中设置cookie显示/隐藏

Javascript jQuery在列表中设置cookie显示/隐藏,javascript,jquery,cookies,Javascript,Jquery,Cookies,如何在列表隐藏/显示功能中设置cookie?所以,如果用户单击“隐藏”,那么当我们刷新页面时,它将记住浏览器仍然通过cookie函数隐藏 函数隐藏 function hideCol(columnClass){ $('table .'+columnClass).each(function(index) { $(this).hide(); }); $('ul#hiddenCols').append('<li id="'+columnClas

如何在列表隐藏/显示功能中设置cookie?所以,如果用户单击“隐藏”,那么当我们刷新页面时,它将记住浏览器仍然通过cookie函数隐藏

函数隐藏

function hideCol(columnClass){
      $('table .'+columnClass).each(function(index) {
        $(this).hide();
      });

      $('ul#hiddenCols').append('<li id="'+columnClass+'"><a href="javascript:;" onclick="showCol(\''+columnClass+'\');">Show '+columnClass+'</a></li>');
    }
请帮助提供建议。

使用jquery cookie 设置cookie在处理函数时显示/隐藏

function hideCol(columnClass){
  $('table .'+columnClass).each(function(index) {
    $(this).hide();
  });

  $('ul#hiddenCols').append('<li id="'+columnClass+'"><a href="javascript:;" onclick="showCol(\''+columnClass+'\');">Show '+columnClass+'</a></li>');
 $.cookie("remember_state","hide"); //add it
}

function showCol(columnClass){
  $('table .'+columnClass).each(function(index) {
    $(this).show();
  });

  $('li#'+columnClass).remove();
     $.cookie("remember_state","show"); //add it
}

@charlietfl使用$.cookie(“记住状态”+列类,“显示/隐藏”)@你需要向我解释的不是我,我知道如何让它工作。你的解决方案不能满足OP的需求
function hideCol(columnClass){
  $('table .'+columnClass).each(function(index) {
    $(this).hide();
  });

  $('ul#hiddenCols').append('<li id="'+columnClass+'"><a href="javascript:;" onclick="showCol(\''+columnClass+'\');">Show '+columnClass+'</a></li>');
 $.cookie("remember_state","hide"); //add it
}

function showCol(columnClass){
  $('table .'+columnClass).each(function(index) {
    $(this).show();
  });

  $('li#'+columnClass).remove();
     $.cookie("remember_state","show"); //add it
}
$(document).ready(function(){
    if($.cookie("remember_state")=="hide"){
    //hide function
}else{
//show function
}
});