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

javascript - How to get current YouTube IDs via iMacros? -

c# - Maintaining a program folder in program files out of date? -

emulation - Android map show my location didn't work -