jquery - How distinguish between same class name -


there endless divs same class name. in example class="box" , evaluate how many letters in respective box. $( ".box p" ).text().lengthyou number of elements in jquery objects. jsfiddle

use each() function loop through these elements , return text length

check demo

$('.box').each(function(index) {   var count = parseint(index) + 1;   $('body').append('<div>box ' + count + ': <span>' + $(this).children('p').text().length + ' letter</div>'); }); 

Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -