jQuery functions to add corresponding entries of lists
I think you could rewrite the code in a shorter way.

You can write the calculateSum# function to be generic.

This you can do by providing the selector or directly the jQuery object you need to loop and sum values.

And instead to directly write the result, you could return the computation.

Of course you could pass the result selector or jQuery element and do the job, but if you return the result, the code is more changeble in the future.

Then you create an object literal with the keys as your element selector, and the values as the result element selector.

And finally create an anonymous function to pass on jQuery document ready step $(myFuncOnDocReadyHere...), where you put all together.

If you prefer to avoid sharing the object with elements you could place it inside the on doc ready function, to keep it "private".

Here is my changes:



var summableAndResult = {
 ".pr1": "#result1",
 ".pr2": "#result2",
 ".pr3": "#result3",
 ".pr4": "#result4"
}

function calculateSum ($list) {
 var sum = 0;

 $list.each(function() {
  var value = $(this).text();
  // test isNaN only if string is not empty
  if (value.length != 0 &amp;&amp; !isNaN(value)) {
   sum += parseFloat(value);
  }
 });
 
 return sum;
}

$(function(){

 for(var el in summableAndResult) {
  var sum = calculateSum($(el));
  $(summableAndResult[el]).text(sum);
 }
 
});
div.col, div.price {float:left}
div.col {width:25%;margin;none;}
ul {list-style-type: none;margin:0;}
&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;html&gt;
&lt;head&gt;
&lt;script type="text/javascript" src="//code.jquery.com/jquery-2.1.0.js"&gt;&lt;/script&gt;
&lt;/head&gt;
&lt;body&gt;
&lt;div class="col price"&gt;
&lt;ul&gt;
&lt;li&gt;Price&lt;/li&gt;
&lt;li class="txt pr1"&gt;150&lt;/li&gt;
&lt;li class="txt pr2"&gt;199&lt;/li&gt;
&lt;li class="txt pr3"&gt;249&lt;/li&gt;
&lt;li class="txt pr4"&gt;299&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="add price"&gt;
&lt;ul&gt;
&lt;li&gt;+&lt;/li&gt;
&lt;li&gt;+&lt;/li&gt;
&lt;li&gt;+&lt;/li&gt;
&lt;li&gt;+&lt;/li&gt;
&lt;li&gt;+&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="col price"&gt;
&lt;ul&gt;
&lt;li&gt;Add costs&lt;/li&gt;
&lt;li class="txt pr1"&gt;27&lt;/li&gt;
&lt;li class="txt pr2"&gt;20&lt;/li&gt;
&lt;li class="txt pr3"&gt;30&lt;/li&gt;
&lt;li class="txt pr4"&gt;39&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="add price"&gt;
&lt;ul&gt;
&lt;li&gt;=&lt;/li&gt;
&lt;li&gt;=&lt;/li&gt;
&lt;li&gt;=&lt;/li&gt;
&lt;li&gt;=&lt;/li&gt;
&lt;li&gt;=&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;div class="col price"&gt;
&lt;ul&gt;
&lt;li&gt;Totaal&lt;/li&gt;
&lt;li&gt;&lt;a id="result1" href=""&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id="result2" href=""&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id="result3" href=""&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a id="result4" href=""&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/body&gt;
&lt;/html&gt;