I'm trying to disable the minus so that the value can not be below zero. So I would like to add some sort of disable when value is <= 0
$("#dynamicContent").on("click", ".qtyplus, .qtyminus", function (e) {
e.preventDefault();
var $input = $(this).closest("div.dynamicWrapper").find(".qty");
var currentVal = parseInt($input.val());
if (!isNaN(currentVal)) {
$(this).hasClass("qtyplus") ? $input.val(currentVal + 1) : $input.val(currentVal - 1);
} else {
$input.val(0);
}
});
I thougt below code would do it. But it didnt
if (currentVal == 0)
{
$('#qtyminus').attr('disabled',true);
} else{
$('#qtyminus').attr('disabled',false);
}