There is a basket of goods, it is necessary that in front of each product, depending on its chosen quantity, the amount is recalculated. The change in quantity is realized, but the calculation is not made, the script counts and changes the price for all the goods at once (if there are a lot of them in the basket).
PS In short: input counter * input price = span sum .
Js
$(document).ready(function() { $('.down').click(function () { var parent = $(this).parent().parent(); var $input = $(this).parent().find('input'); var countn = parseInt($input.val()) - 1; var count = parseInt($input.val()) - 1+' шт.'; countn = countn < 1 ? 1 : count; $input.val(countn); $input.change(); return false; }); $('.up').click(function () { var $input = $(this).parent().find('input'); $input.val(parseInt($input.val()) + 1+' шт.'); $input.change(); return false; }); }); HTML
<div class="goods"> <div class="name">Название товара</div> <div class="goods-count"> <span class="amount"> <span class="down">-</span> <input type="text" class="counter" value="1 шт." /> <input type="hidden" class="price" value="5000" /> <span class="up">+</span> </span> </div> <div class="goods-price"><span class="sum">5000</span> руб.</div> </div>