[英]Why this jQuery cookie doesn't get retrieved?
我有兩個div的代碼,就像單選按鈕一樣,它們表現良好,但我設置的cookie在頁面刷新時無法檢索。
var isboxed = $.cookie('boxed_cookie');
if (isboxed = 'isboxed'){
$('.wrap').addClass("boxed");
} else {
$('.wrap').removeClass("boxed");
}
var selectors = $('#sbox-boxed-layout div');
selectors.on('click', function(e){
var $this = $(this);
selectors.removeClass('selected').addClass('disabled');
$this.addClass('selected').removeClass('disabled');
if ($('#sbox-boxed-layout div.on').hasClass('selected')){
$('.wrap').addClass("boxed");
$.cookie('boxed_cookie', 'isboxed' , { expires: 7, path: '/' });
} else {
$('.wrap').removeClass("boxed");
$.cookie('boxed_cookie', 'isfull' , { expires: 7, path: '/' });
}
});
if (isboxed = 'isboxed'){
應使用==
(double-equals)進行比較。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.