2017-08-03 59 views
-1

在右側的數量在下面的輸入和Order按鈕的腳本爲什麼我的數量微調腳本不工作?

<div class="clear" id="dvQty"> 
    <p class="qty-label">Qty:</p> 
    <div class="qty-plus" id="divup">+</div> 
    <div class="qty-input"> 
    <input name="vwquantity" value="1" class="qty-input" type="text"> 
    </div> 
    <div class="qty-minus" id="divdown">-</div> 
    <div class="add2cart fl"><input value="Add to Cart" class="ys_primary" title="Add to Cart" type="submit"><input name="vwcatalog" value="bodylogic" type="hidden"><input name="vwitem" value="herbal-select-creme-gallon" type="hidden"></div> 

</div> 

JS

$("#txtQty").numeric(); 
$("#divup").click(function() { 
    var qty = $("#txtQty").val(); 
    qty++; 
    $("#txtQty").val(qty); 
}); 
$("#divdown").click(function() { 
    var qty = $("#txtQty").val(); 
    if(qty > 1) { 
    $("#txtQty").val(qty - 1); 
    } 
}); 

什麼我只是沒有看到?

+0

Your input doesn '沒有id'txtQty'就可以了。 – H77

回答

0

添加id="txtQty"到您的輸入,因爲你叫$("#txtQty"),更換

<input name="vwquantity" value="1" class="qty-input" type="text"> 

<input id="txtQty" name="vwquantity" value="1" class="qty-input" type="text"> 

.numeric()不是jQuery的內置函數刪除它,它似乎沒有jQuery的,加line below your html body

<script src="https://cdn.jsdelivr.net/jquery/1.12.4/jquery.min.js"></script> 
+0

謝謝,ewwink。必須使輸入「vwquantity」的ID由於購物車腳本需要看到的內容而在此平臺上,我無法訪問購物車服務器。我確定我已經在head標籤中調用了jQuery。所以我確定我從未檢查過。但你做到了。我很感激。解決這些問題使一切工作。 –