Of all the <p> blocks, select one or two containing the largest text size inside.

Interested in jscript, css, jquery or php code, etc.

Or just a general principle.

  • always pleased with the total landfill when php equate to js, ​​css, jquery))) - thunder

2 answers 2

 var maxlen = 0; var maxLenLink = null; $('p').each(function(){ if($(this).text().length>maxlen){//и правда maxlen = $(this).text().length; maxLenLink = $(this); } }); maxLenLink.css({'color':'red'}); 
     var max = 0; var index = 0; $("p").each(function(){ var height = $(this).height(); if(height > max){ max = height; index = $(this).index(); } }); alert("Max height:"+max+" . It's Index: "+index);