var A = $('.mainmenu ul li'), max = 0, elem; A.each(function () { if (this.offsetWidth > max) max = this.offsetWidth, elem = this; });