1👍
✅
use a cookie easy and nice.
you can set a cookie like the below and then read it through the javascript
set cookie:
document.cookie="checkbox=true";
read cookie on next page
var value = readCookie('checkbox');
create a function which allows you to get the value back each time
function readCookie(name) {
var nameEQ = name + "=";
var ca = document.cookie.split(';');
for(var i=0;i < ca.length;i++) {
var c = ca[i];
while (c.charAt(0)==' ') c = c.substring(1,c.length);
if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
}
return null;
}
so now when you compare it with the click you can do something like this:
$(".checkbox").click(function(e){
var checked = $(this).is(':checked');
if (checked == undefined || null){
checked = readCookie('checkbox');
}
if(checked==true){
//display those content
}
});
Source:stackexchange.com