SO fiddle
Test Fiddle mainly for SO Questions
by Nick Craver
HTML
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.4/themes/overcast/jquery-ui.css">
<h2>Test</h2>
<h2>Test Longer</h2>
<h2>Test</h2>
<h2>Test Even Longer!</h2>
<h2>Test</h2>
CSS
h2 { display: inline; }
.widest { color: red; }
JavaScript
var cw = 0, widest;
$("h2").width(function(i, w) { console.log(w, cw); if(w > cw) {widest = this; cw = w;} return w; });
$(widest).addClass("widest");