You need to use .each() correctly, so read the article carefully.
It clearly states that the method has one use case:
.each (callback (index, domElement))
You do not pass any parameters to the callback. So we just need to rewrite the code a bit. The markup did its, but the principle is clear:
function getSum() { var $target = $('.term'), sum = 0; //тот кусок, который вам нужен $target.each(function(idx, item) { sum += parseInt($(this, item).val()) || 0; }); $('.sumInput').val(sum); $('.sum').text(sum); } document.getElementById('getSum').addEventListener('click', getSum, false);
input { display: block; }
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script> <input type="text" class="term" placeholder="Слагаемое" /> <input type="text" class="term" placeholder="Слагаемое" /> <input type="text" class="term" placeholder="Слагаемое" /> <input type="text" class="term" placeholder="Слагаемое" /> <input type="button" id="getSum" value="Посчитать" /> <input type="text" class="sumInput" placeholder="Сумма" /> <div class="sum"></div>