通过使用jquery和javascript单击另一个li删除一个li
单击另一页上的另一个li删除li时出现问题。。并且删除li id存在于localStorage变量中 在同一页上有两个div。 第一个李代码是通过使用jquery和javascript单击另一个li删除一个li,javascript,jquery,html,cordova,Javascript,Jquery,Html,Cordova,单击另一页上的另一个li删除li时出现问题。。并且删除li id存在于localStorage变量中 在同一页上有两个div。 第一个李代码是 <div data-role="page" id="wishListPage" data-add-back-btn="true"> <div data-role="header" data-position="fixed"> <header id="mainHeader
<div data-role="page" id="wishListPage" data-add-back-btn="true">
<div data-role="header" data-position="fixed">
<header id="mainHeader" align="center">
<a href="#"><img src="images/logoName.png" /> </a>
</header>
</div>
<div data-role="content" data-theme="a" id="wishProducts">
<ul id="wishList" data-role="listview"></ul>
</div>
</div>
这里的愿望列表是ul的id。。
而存储在本地的存储代码是
function saveValuesInLocalStorage(productUrl, productName , productImageName , vendorImage , fixedPrice, finalPrice, authorName,sharingUrl){
localStorage.sharingUrl = sharingUrl;
localStorage.productUrl = productUrl;
localStorage.productName = productName;
localStorage.imageName = productImageName;
localStorage.vendorImage = vendorImage;
localStorage.fixedPrice = fixedPrice;
localStorage.finalPrice = finalPrice;
localStorage.authorName = authorName;
}
现在我想删除id为localStorage.productUrl
对话框页面为:
<div data-role="content" data-theme="a">
<ul name="options" id="options" data-role="listview">
<li>
<a href="#" data-theme="a" data-ajax="false" onClick=" removeInfoDatabase()">
<p><span id="itemName"><h4>Remove from wish List</h4></span></p>
</a>
</li>
<li>
<a href="javascript:void(0);" data-theme="a" data-ajax="false" onclick="openWebLink()">
<p><span id="itemName"><h4>Go to Store</h4></span></p>
</a>
</li>
</ul>
</div>
现在,单击“从愿望列表中删除”按钮后,我如何删除愿望列表
请帮帮我。。请
提前感谢..假设这两个页面位于同一站点上(这样它们共享相同的
localStorage
对象),最简单的选择是在将要删除元素的页面上使用setTimeout()
,轮询本地存储是否存在ID
function pollStorage() {
var id = localStorage.id;
if (typeof id !== 'undefined') {
delete localStorage.id;
$(id).remove();
}
setTimeout(pollStorage, 100);
}
pollStorage();
我们对此无能为力。提供详细信息、代码示例和测试用例。这两个页面在同一个站点上?@BramVanroy我们当然可以做些什么!
function removeInfoDatabase (){
db.transaction(removeElement, removeError, removeSuccess);
}
function removeError(err){
console.log("Error processing SQL: "+err.code);
alert("couldn't remove from wish list");
}
function removeSuccess(){
var elem =document.getElementById(localStorage.productUrl);
elem.parentNode.removeChild(elem);
// $("#"+localStorage.producturl).remove();
// var mm = $("#"+localStorage.producturl).html();
// alert(""+mm);
$("#wishList").listview("refresh");
alert("item is removed successfully");
history.back();
}
function removeElement(tx){
tx.executeSql('CREATE TABLE IF NOT EXISTS itemDetail (id unique, productName , imageName, vendorImageName , fixedPrice , finalPrice , authorName , sharingUrl)');
tx.executeSql('DELETE from itemDetail where id="'+localStorage.productUrl+'"');
}
function pollStorage() {
var id = localStorage.id;
if (typeof id !== 'undefined') {
delete localStorage.id;
$(id).remove();
}
setTimeout(pollStorage, 100);
}
pollStorage();