我有一個網站,用戶可以選擇一個項目,細節然後顯示,包括數量。我也包括在div內的按鈕,以便單擊時,它應該由1JavaScript的按一下按鈕功能不能正常工作
$("#btnBuy1").click(function()
{
if (!sessionStorage['quantity1'])
{
sessionStorage['quantity1']=1;
}
else
{
sessionStorage['quantity1']++;
}
$("#dropbox").html('<div id = "1"><img class = "thumb" id = "t1" src="../images/birthday_metoyou.jpg" />' + teddy[1].desc + ", Price £"
+ teddy[1].price + ", Quantity: " + sessionStorage.getItem('quantity1') + "<button id = 'btnRemove1'>Remove</button></div><br/>");
updateBasket();
sessionStorage["total1"] = parseInt(sessionStorage.getItem('quantity1')) * teddy[1].price;
updateSubtotal();
if (Modernizr.sessionstorage)
{ // check if the browser supports sessionStorage
myids.push(teddy[1].partnum); // add the current username to the myids array
sessionStorage["ids"]=JSON.stringify(myids); // convert it to a string and put into sessionStorage
}
else
{
// use cookies instead of sessionStorage
}
});
$("#btnRemove1").click(function()
{
alert(remove);
});
我把一條警告消息減少量,看看是否按鈕是否工作正常,但是當我點擊btnRemove1按鈕,沒有任何反應。
哪裏是你的HTML代碼加載?你使用的是什麼版本的jQuery? – DaveHogan 2013-03-27 17:41:02
你不應該在這裏通知一個字符串嗎? 'alert(remove);' – 2013-03-27 17:41:12
你可以在你創建btnRemove1的地方添加代碼嗎? btnBuy1點擊功能是否按預期工作? – FloatingCoder 2013-03-27 17:43:23