There is an HTML report, where I've applied style as The data fills dynamically so I need to detect if there is a existing or not in the report. 。数据是动态填充的,因此我需要检测报告中是否存在 。 After researching over many forums, which all suggest comparing the scrollHeight
and clientHeight
, I tried this:
$( document ).ready(function() {
var myReport = document.getElementById("report_id");
if (myReport.scrollHeight > myReport.clientHeight) {
alert("has a scrollbar");
} else {
alert("has NO scrollbar");
}
});
This does not work. The result is always true, ie "has a scrollbar", even when there's no vertical scrollbar.
Please suggest.
PS: The above code is just for testing purpose.
<script>
jQuery(document).ready(function(){
var outerHeight = $("#report_id").outerHeight();
var scrollHeight = $('#report_id')[0].scrollHeight
if (outerHeight < scrollHeight) {
alert("has a scrollbar");
}
else
{
alert("has NO scrollbar");
}
});
</script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.