I am very new to this, just trying to collect fragments from other posts.
I'm not sure how to count the number of elements on a page, and then add a class to distinguish them from the number.
<script type="text/javascript">
$(document).ready(function(){
$('.item').each(function (e) { $(this).addClass('count' + e); });
});
</script>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
conclusion:
<div class="item count1"></div>
<div class="item count2"></div>
<div class="item count3"></div>
source
share