2017-08-03 56 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。所以我确定我从未检查过。但你做到了。我很感激。解决这些问题使一切工作。 –