This question has already been answered:
- Loss of context call 5 responses
$(".cartProduct").each(function() { var priceOfProduct = $(this).children(".priceOfProduct").text(); var numberOfProductCart=1; $(this).children(".sumPriceOfProduct").text(numberOfProductCart*priceOfProduct); $(this).find('.shest').keyup(function() { numberOfProductCart = $(this).val(); $(".sumPriceOfProduct").text(numberOfProductCart*priceOfProduct); }); }); The sumPriceOfProduct class is a child of cartProduct , which has an infinite number of pieces. It is necessary that sumPriceOfProduct in each cartProduct independently, I thought this would help here, but with this it calls the anonymous function at the keyup event, but it is necessary for the cartProduct to cartProduct .