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')
? ? ? ? }
? ? ?}
? }
}
應該怎么加呢,
添加回答
舉報