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 或 javascript 检测具有多个属性的选择框是否可滚动(即列表中有足够的元素需要滚动选择框)?
问候,
玛丽
您需要将height()元素的可见性与进行比较scrollHeight,如下所示:
height()
scrollHeight
if ($('#foo').height() < $('#foo')[0].scrollHeight) { alert('scrollable'); }
示例小提琴