javascript - Get widest element in a jQuery set -


let's have bunch of <span> elements different text content.

how can widest <span>?

jquery fine. care identifying span, not value of width itself.

a similar question here. value of width.

here's how i'd start:

$('span').each(function(id, value){   if ($(this).width() > w) {     largestspan = id;   } }); 

var maxwidth = 0; var widestspan = null; var $element; $("span").each(function(){    $element = $(this);    if($element.width() > maxwidth){      maxwidth = $element.width();      widestspan = $element;     }  }); 

Comments

Popular posts from this blog

Load Balancing in Bluemix using custom domain and DNS SRV records -

oracle - pls-00402 alias required in select list of cursor to avoid duplicate column names -

python - Consider setting $PYTHONHOME to <prefix>[:<exec_prefix>] error -