Hi, I am having a little bit of problem deleting a specific cookie. I have created the cookie successfully but the problem is deleting the cookie when a specific del id has been invocked. This is the complete code, can someone please point out what I am missing and if possible, guide me by helping me fix it?
jQuery(function($){
$("a[id^='savebook-']").click(function(){
match = this.id.match(/savebook-(\d+)/);
savedclass = $("span#saved-"+match[1])
savedclass.addClass("saved");
var bookid = +match[1];
var delim = "|"; // delimiter for books in cookie
// get the previous cookie (if any), split it into an array
var books = ($.cookie("books_saved") || "").split(delim);
books.push(bookid);
$.cookie("books_saved", books.join(delim), { expires: 7, path: '/', domain: 'example.com'});
return false;
});
$("a[id^='delbook-']").click(function(){
xmatch = this.id.xmatch(/delbook-(\d+)/);
var delim = "|";
var delid = xmatch[1];
var books = ($.cookie("books_saved") || "").split(delim);
var i = null;
for (i = 0; books.length > i; i += 1) {
if (books[i].delid === delid) {
books_saved.slice(delid)
}
}
});
});