所以我设法得到它,所以当我单击按钮向收藏夹添加东西时,它禁用了按钮。但是当我刷新按钮时,可以再次单击该按钮。
我想拥有它,所以当我单击按钮时,图标的属性会发生变化,例如“添加到收藏夹”并保持禁用状态,但是说“添加到收藏夹”,直到我进入收藏夹并删除该项目从我的本地存储中。
我希望我上面的解释是可以理解的
有没有办法实现这一目标?
(询问您是否需要其他代码来帮助我解决我的情况)
$(document).ready( function() {
$("#add_btn").on("tap", function(){
var propName = $("#propName").text();
var propPrice = $("#propPrice").text();
var pageURL = $(location).attr("href");
localStorage.setItem("propName", propName);
localStorage.setItem("propPrice", propPrice);
localStorage.setItem("prop", pageURL);
$('#pFave').html("Property added to Favourites");
$("#popupFave").popup("open", "reposition", 'positionTo: window');
$("#add_btn").attr("disabled", true);
});
var propLength = window.localStorage.length;
console.log(propLength);
if(propLength !=0){
var hName = localStorage.getItem("propName");
var hPrice = localStorage.getItem("propPrice");
var url = localStorage.getItem("prop");
var list = "<li><a href='"+ url +"' data-ajax='false'>" +hName +"<br> "+hPrice + "</a><button id='remove' class='ui-btn ui-corner-all'>Delete</button></li>";
$('#listProperties').append(list).listview('refresh');
$('#remove').on("tap", function(){
localStorage.removeItem("propName");
localStorage.removeItem("propPrice");
localStorage.removeItem("prop");
window.location.reload();
});
} else {
var list = "<li data-icon='false'><a href='#' data-ajax='false'>No Properties Saved</a></li>";
$('#listProperties').append(list).listview('refresh');
}
});