我尝试以此格式enter link description here
将最大数量设置为10请问怎么可能这样做? 谢谢
答案 0 :(得分:0)
请尝试在代码中添加验证:
$('.qtyplus').click(function(e){
// Stop acting like a button
e.preventDefault();
// Get the field name
fieldName = $(this).attr('name');
// Get its current value
var currentVal = parseInt($('input[name='+fieldName+']').val());
// If is not undefined
if (!isNaN(currentVal) && currentVal < 10) {
// Increment
$('input[name='+fieldName+']').val(currentVal + 1);
} else {
// Otherwise put a 0 there
$('input[name='+fieldName+']').val(1);
}
});