如何检测滚动框(html元素)是否可滚动 [英] How can you detect if a scroll box (html element) is scrollable
本文介绍了如何检测滚动框(html元素)是否可滚动的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
问候,
Mary
解决您需要比较元素的可见
height()
与 scrollHeight
,像这样: if($('#foo')。height()< $('#foo') [0] .scrollHeight){
alert('scrollable');
}
Weird question, but I would like to know if there is a possible way of detecting if a select box with the multiple attribute is scrollable (i.e. enough elements in list to require the scrolling of the select box) via jQuery or javascript ?
Regards,
Mary
解决方案
You need to compare the visible height()
of the element to the scrollHeight
, something like this:
if ($('#foo').height() < $('#foo')[0].scrollHeight) {
alert('scrollable');
}
这篇关于如何检测滚动框(html元素)是否可滚动的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文