не будет быстрым, но должно сработать
var widest = null;
$("*").each(function() {
if (widest == null)
widest = $(this);
else
if ($(this).width() > widest.width())
widest = $(this);
});
это должно сработать
эта версия может быть немного быстрее (но определенно не так уж и популярна):
var widest = null;
// remember the width of the "widest" element - probably faster than calling .width()
var widestWidth = 0;
$("*").each(function() {
if (widest == null)
{
widest = $(this);
widestWidth = $(this).width();
}
else
if ($(this).width() > widestWidth) {
widest = $(this);
widestWidth = $(this).width();
}
});
Я также предлагаю вам ограничить тип узлов, через которые вы проходите (т.е. используйте div вместо *)