javascript - Store multiple values in localStorage when clicked on -


so im trying have jquery remember clicked on.

so user clicks on list item , clicks on list item. how store both item classes user clicked on.

here have currently

$(document).ready(function() {     $('#terms-product_cat ul li').on('click', function(event) {         $(this).addclass('current-term');         window.localstorage['temp_type'] = $(this).find('label').attr('class');     });     alert(window.localstorage['temp_type']); }); 

try this:

$('#terms-product_cat ul li').on('click', function(event) {     $(this).addclass('current-term');     var maybe_string = window.localstorage['temp_type'];     var array = maybe_string ? json.parse(maybe_string) : [];     array.push($(this).find('label').attr('class'));     window.localstorage['temp_type'] = json.stringify(array); }); 

Comments

Popular posts from this blog

Unable to remove the www from url on https using .htaccess -