Done!

How to loop through all the elements having same class in JQuery


Lets assume you have the following html tags with class="stats"

<ul>
    <li>< span class="stats" id="logins">8,216 </span> 
    <li>< span class="stats">2,123< /span> 
    <li>< span class="stats">11,001< /span> 
</ul>

To Loop through every element and get value, use JQuery each loop as below

$('.stats').each(function(i){
    var statsValue = $(this).html(); 

    console.log(statsValue);
});

On the firebug or Chrome Console Terminal the output of above loop would be:

-> 8,216
-> 2,123
-> 11,001

Thanks