Why does this code not delete the cookie?
I'm doing what should be fairly easy, I'm creating a cookie which holds a bunch of user defined variables and puts them into a list.
I am then trying to allow the person to delete an item from the list, which will remove it from the cookie.
The code to remove an item from the list looks like this
jQuery('a.removeFromList').live('click', function(){
// put the userList into a holder so I can go through the variable list and only remove the one the user clicked
var holdList=userList;
// delete the entire userList
jQuery.cookie('userList',null,{ expires: -1 });
// go through the holdList
for(or=0;or<holdList.items().length;or++){
// this should return "null", but doesn't
alert(userList.item开发者_运维百科s());
if(holdList.items()[or]!=jQuery(this).attr('id')){
// this is a function which adds the data to the cookie.
userList.add(holdList.items()[or]);
}
}
showList(userList,jQuery('ul#userList').data('data'));
});
I'm using the code I found on this page to build a comma seperated list to the items, and to get the items. how to store an array in jquery cookie? I've also tried using the userList.clear() to delete the cookie, but that hasn't worked either.
jQuery.cookie(...)
is generating 'Object does not support this property or method'
Have you correctly included a link to the JQuery cookie plugin script?
http://plugins.jquery.com/node/1386/release
Same problem with this line
holdList.items()
is generating 'Object does not support this property or method'
精彩评论