User-2059141420 posted
Hi all,
I'm creating an input number increment using jQuery but no success yet
My code as
HTML
<div class="sp-quantity">
<div class="sp-minus fff"> <a class="ddd" href="#">-</a></div>
<div class="sp-input">
<input type="text" value="5">
</div>
<div class="sp-plus fff"> <a class="ddd" href="#">+</a></div>
</div>
JS
$(".ddd").on("click", function () {
var $button = $(this);
var oldNo = $button.parent().find("input").val();
if ($button.text() == "+") {
var newNo = parseFloat(oldNo) + 1;
} else {
// Don't allow decrementing below zero
if (oldNo > 0) {
var newNo = parseFloat(oldNo) - 1;
} else {
newNo = 0;
}
}
$button.parent().find("input").val(newNo);
});
Please help me to fix this problem. Thanks!