gpt4 book ai didi

jquery - 如何使用这个 jQuery 插件删除 cookie?

转载 作者:行者123 更新时间:2023-12-03 22:54:07 25 4
gpt4 key购买 nike

首先,为了显示 cookie,我使用了 electrictoolbox.com 中的代码.

然后我制作了一个表单来添加一些 cookie:

<form class="cokies" method="post">
<input class="query" name="q" type="text" />
<input type="submit" name="save" value="saving">
<a>Delete Cookies</a>
</form>
$(document).ready(function(){
$('.cokies a').click(function(){
$.cookie('q', null);
});

remember('[name=q]');

该函数来自komodomedia.com :

function remember( selector ){
$(selector).each(function(){
//if this item has been cookied, restore it
var name = $(this).attr('name');
if( $.cookie( name ) ){
$(this).val( $.cookie(name) );
}

//assign a change function to the item to cookie it
$(this).change(function(){
$.cookie(name, $(this).val(), { path: '/', expires: 365 });
});
});
}

问题是,我不知道如何删除 cookie。

最佳答案

要删除 cookie,只需将 expires: 设置为负整数值即可。

示例:

$.cookie(name, $(this).val(), { 路径: '/', 过期时间: -5 });

关于jquery - 如何使用这个 jQuery 插件删除 cookie?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1623728/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com