Answer the question
In order to leave comments, you need to log in
How to calculate the amount for the number of products in javascript?
Good day!
There is such a code
<td>
<input type="text" name="count-item" id="count" value="1">
</td>
<span id="cost">52.5</span>
<span id="result"></span>
Answer the question
In order to leave comments, you need to log in
var cost = document.getElementById('cost');
var count = document.getElementById('count');
var result = document.getElementById('result');
count.addEventListener('change', function() {
result.textContent = parseInt(count.value, 10) * parseFloat(cost.textContent);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question