我希望显示 3 个不同的 div 第一次访问时显示 1 个 div 第二次访问时显示第二个 div 第三次访问时显示第三个 div
我以为我有代码可以实现这一点,但它不起作用,我无法弄清楚我做错了什么。
$(document).ready(function() {
var cookieRCCS = $.cookie('shownDialog');
console.log(cookieRCCS);
// Check if the cookie exists.
if ( cookieRCCS === null ) {
console.log("1st if statement " + cookieRCCS);
$("#hellopanel1").show();
// set the cookie to value 1
$.cookie('shownDialog', '1', {expires: 7});
}
else if ( cookieRCCS === 1 ) {
console.log("2nd if statement " + cookieRCCS);
$("#hellopanel2").show();
// If the cookie exists, take the value
cookie_value = $.cookie('shownDialog');
// Convert the value to an int to make sure
cookie_value = parseInt(cookie_value);
// Add 1 to the cookie_value
cookie_value++;
// Save the incremented value to the cookie
$.cookie('shownDialog', cookie_value, {expires: 7});
}
else if ( cookieRCCS === 2){
console.log("3rd if statement " + cookieRCCS);
$("#hellopanel3").show();
cookie_value = $.cookie('shownDialog');
cookie_value = parseInt(cookie_value);
cookie_value++;
$.cookie('shownDialog', cookie_value, {expires: 7});
}
else{
console.log("4th Time Here");
}
});