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.
我制作了一个菜单,其中最后一项超过了它的父母宽度。
如何使用 jquery 检测子元素是否超过了它的父宽度?
简单的例子:
var child = $('.child'); var child_w = child.width(); var parent_w = child.parent().width(); if(child_w > parent_w) { alert('AHHHH!'); }