sum int array values

we will loop to sum all values :
if we have an array like

<ul>
<li class='price'>10</li>
<li class='price'>5</li>
<li class='price'>3</li>
<li class='price'>11</li>
</ul>
summ will get by :

$('.price').blur(function () {
    var sum = 0;
    $('.price').each(function() {
        sum += Number($(this).html());
    });
});​​​​​​​​​


Comments

Popular posts from this blog

C# Crop white space from around the image

Could not load file or assembly 'Microsoft.ReportViewer.Common, Version=xx.0.0.0, Culture=neutral, PublicKeyToken='xxx' or one of its dependencies.

The specified version string contains wildcards, which are not compatible with determinism.