I have a problem in product listing quantity counter, sometimes it will work and sometimes it will not. I want to create custom JQuery script to enable product counter increment and decrement, But the problem is that, it is a listing page so if I create script others will be affected. Please correct me if I'm wrong.
Below attached is screenshot.
Here's my script that is working in product detail page only.
var $currentQTY=parseInt($('#qty').val());
$(".qty-inc").click(function(){
$currentQTY=$currentQTY+1;
$('#qty').val($currentQTY);
// console.log($currentQTY);
});
$(".qty-dec").click(function(){
$currentQTY=$currentQTY-1;
if ($currentQTY<1){
$currentQTY=0;
}
$('#qty').val($currentQTY);
// console.log($currentQTY);
});
Thanks