how to Keep checkbox checked after refresh the page

前端 未结 1 1734
暗喜
暗喜 2020-12-12 04:39

I have a drop down box when selecting from the drop down its shows the data also i have check box above the each td ,this check box is used to hide the column this perform b

相关标签:
1条回答
  • 2020-12-12 04:56

    Use localStorage for it.

    Here is JSFiddle Example of it. Link

    Code behind it:

    HTML Code:

    <input type="checkbox">
    

    JS Code:

    $(function(){
        var test = localStorage.input === 'true'? true: false;
        $('input').prop('checked', test || false);
    });
    
    $('input').on('change', function() {
        localStorage.input = $(this).is(':checked');
        console.log($(this).is(':checked'));
    });
    
    0 讨论(0)
提交回复
热议问题