我有这样的代码:
jQuery(document).ready(function($) {
$( "#tabs" ).tabs({
collapsible: true,
fx: { height: 'toggle', duration: 'fast'},
cookie: { expires: 30 }
});
});我使用带有cookie集的jQuery选项卡。如果没有设置cookie,我想隐藏选项卡。我已经安装了所需的jquery.cookie插件。
我的问题
如何检查选项卡cookie是否已设置?
发布于 2011-10-18 08:57:35
你应该用一套
//getter
var cookie = $( ".selector" ).tabs( "option", "cookie" );
//setter
$( ".selector" ).tabs( "option", "cookie", { expires: 30 } );编辑
为Cookie设置名称,并使用getter和setter
$("#selector").tabs({
cookie: {
name: 'mycookie',
expires: 10
}
});
Get the Cookie
alert($.cookie('mycookie'));
Set the Cookie
$.cookie('mycookie', null);发布于 2011-10-18 08:14:37
你不能用cookie.js的getter方法来做吗:
* Get the value of a cookie with the given key.
*
* @example $.cookie('the_cookie');
* @desc Get the value of a cookie.
*
* @param String key The key of the cookie.
* @return The value of the cookie.
* @type String 有点像
var cookieVal = $.cookie('ui-tabs-1');https://stackoverflow.com/questions/7804217
复制相似问题