Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一个div包含大约 100 个其他div元素。每个div元素都有top和left属性。如何找到div具有最大left属性的? 我需要最好的表现。谢谢。
div
top
left
试试这个,
现场演示
var divWithTopLeft = null; var maxLeft = 0; $('div').each(function(){ left = this.style.left.replace('px',''); if(left > maxLeft ) { maxLeft = left; divWithTopLeft = this; } });