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().length
you 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
Post a Comment