Hello to all! localStorage.setItem does not work I can not understand the reason. When clicked, everything works, but after the update in the browser, all classes disappear, but should have been saved. thank
// Product Grid $('#grid-view').click(function() { // What a shame bootstrap does not take into account dynamically loaded columns $('#content .list-product').attr('class', 'col-md-4 col-sm-6 product_main grid-product'); $('#list-view').removeClass('active'); $('#grid-view').addClass('active'); localStorage.setItem('display', 'list'); }); if (localStorage.getItem('display') == 'list') { $('#list-view').trigger('click'); $('#list-view').addClass('active'); } else { $('#grid-view').trigger('click'); $('#grid-view').addClass('active'); } // Product List $('#list-view').click(function() { //$('#content .product-grid > .clearfix').remove(); $('#content .row > .grid-product').attr('class', 'col-md-12 product_main list-product'); $('#grid-view').removeClass('active'); $('#list-view').addClass('active'); localStorage.setItem('display', 'list'); });
$(function(){...})if it is not there yet, or before the closing body tag - Grundyif (localStorage.getItem('display') == 'list') { ...after both$(...).click(function() { ...- Igor