2 回答
TA贡献5条经验 获得超1个赞
$("#menu_carage").append("<button class='input11' >购买数量:</button> <span class='cut' onclick='numWay()'>-</span><input " +
"class='cart11'id='num' value='1' oninput='v()'></input><span class='plus' onclick='numWay()'>+</span><br><button id='unit_price'>您的单价:</button><select " +
"id=shopage_"+fid+">" +
"<option class='option_price' value='0'> "+fprice+"元 </option></select><br><button class='input11' " +
" id = 'totalp'>您的总价:</button><input " +
"class='cart11'id='totalnum'readonly='readonly' value="+fprice+'元'+"></input><input hidden='YES'id='price'" +
"value="+fprice +"></input>");
}
function numWay() {
var num_box = document.getElementById("menu_carge");
var spans = num_box.getElementsByTagName("span");
var input = document.getElementById("num");
for (var i = 0; i < spans.length; i++) {
spans[i].onclick = function () {
var val = parseInt(input.value);
if (span[i].className == "plus") {
input.value = val + 1;
}
else {
if (val > 1) {
input.value = val - 1;
}
alert('11')
}
}
}
}
应该怎么加呢,
添加回答
举报