Cookie:
$(document).ready(function(){
//hide all divs for the purpose of this example, you should have them hidden with your CSS
//$('.picture.1').hide();
//check if the cookie is already set
if ($.cookie("currentDiv") === undefined){
$.cookie("currentDiv", 1);
} else {
//get and increment value, assuming we have only 8 divs
var numValue = parseInt($.cookie("currentDiv"));
numValue = numValue + 1;
if (numValue > 8){
//restart to 1
$.cookie("currentDiv", 1);
}
else {
$.cookie("currentDiv", numValue.toString());
}
//show the div
$('.picture.' + $.cookie("currentDiv")).show();
$('.current' + $.addClass(.cookie("currentDiv")); <--
}
});
Div:
<div class="current"></div>
I have set styles from 1 to 8, so if it is "current 1," it displays the number 1. The cookie functions by setting a cookie named 'currentDiv' with a number from 1 to 8, and it refreshes the cookie if the value goes beyond 8. Now, the challenge is how to add that class to the div using this cookie and jQuery. It needs to add a class to prevent browsing data, and I have an SVG with numbers from 0 to 9
Thank you, Sake