不会很快,但应该做的伎俩
var widest = null;
$("*").each(function() {
if (widest == null)
widest = $(this);
else
if ($(this).width() > widest.width())
widest = $(this);
});
Run Code Online (Sandbox Code Playgroud)
这应该可以解决问题
这个版本可能会稍微快一点(但绝对不是那么clienat):
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();
}
});
Run Code Online (Sandbox Code Playgroud)
我还建议你限制你经历的节点类型(即使用div而不是*)
归档时间: |
|
查看次数: |
3064 次 |
最近记录: |