JSFiddle - React, Tailwind, and code Playground
HTML
<div class="tovar" id="41">
<div class="tovar-price-42">2</div>
<input class="tovar-count" id="tovar-count-41" type="text" value="2" size="3"><span class="plus"></span><a href="#" class="check">Получить значения "кол-ва" и "цены" для первого товара с id="41"</a>
</div>
<div class="tovar" id="42">
<div class="tovar-price-42">4</div>
<input class="tovar-count" id="tovar-count-42" type="text" value="3" size="3"><span class="plus"></span><a href="#" class="check">Получить значения "кол-ва" и "цены" для второго товара с id="42"</a>
</div>
JavaScript
$(document).ready(function () {
$('.check').click(function () {
var product_id = this.id;
alert(product_id);
var product_amount = $("#tovar-count-" + product_id + "").val();
product_amount = parseInt(product_amount);
alert(product_amount);
var product_amount1 = $("#tovar-price-" + product_id + "").text();
product_amount1 = parseInt(product_amount1);
alert(product_amount1);
});
});