我有一个网站,用户可以选择一个项目,细节然后显示,包括数量。我也包括在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