我已添加到我的本地存储空间以在应用上创建收藏夹部分我不想使用其他按钮删除。删除不会有任何想法为什么?
//Add Favorites
$('.favoritesbtn').click(function() {
var storedbar = JSON.parse(localStorage.getItem('storedBar'));
var favArray = [];
favArray.push(storedbar.id, storedbar.barname, storedbar.address, storedbar.description, storedbar.image);
localStorage.setItem('favourites', JSON.stringify(favArray));
console.log(localStorage.getItem('favourites'));
});
//Removing favorites
$('.removebtn').click(function () {
localStorage.removeItem('favorties', JSON.stringify(favArray));
});
答案 0 :(得分:1)
您只需要传递项目的键即可删除:
x = 400