5

我有一个div包含大约 100 个其他div元素。每个div元素都有topleft属性。如何找到div具有最大left属性的?
我需要最好的表现。谢谢。

4

1 回答 1

3

试试这个,

现场演示

var divWithTopLeft = null;
var maxLeft = 0;
$('div').each(function(){
    left = this.style.left.replace('px','');
    if(left > maxLeft )
    {
         maxLeft = left;
         divWithTopLeft = this;
    }   
});
于 2012-07-09T11:24:27.010 回答