Loop with each()

Run code for every matched element. this is the DOM element, so wrap it in $().

jQuery · Loop with each()Beginner
let total = 0;

$('.price').each(function (index) {
  const value = parseFloat($(this).text());
  total += value;
  $(this).text('Rs ' + value.toFixed(2));
});

$.each(['a', 'b'], function (i, item) {
  console.log(i, item);
});
eachloopcollection