首先,爲了顯示cookie,我使用了來自electrictoolbox.com的代碼。如何使用這個jQuery插件刪除一個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 });
});
});
}
的問題是,我不知道如何刪除一塊餅乾。
是的,這是工作。謝謝 – 2009-10-27 04:52:02
如果它有效,請給它一個答案,其他誰來這個問題知道正確的答案。 – mauris 2009-10-27 06:38:05