![](/img/trans.png)
[英]How to constantly check whether there is div overflow and then scroll to the bottom
[英]How to find the width of the div or check whether horizontal scroll appears or not?
如果该 div 没有出现水平滚动,我想打印页面 (div)。 我有一个带有动态数据的 div (1000px),它有属性overflow:auto;
. 所以,只有当 div 的宽度没有被交叉时,我才想打印 div。 为了实现这一点,我使用了以下 Javascript 方法
var curr_width = parseInt(mydiv.style.width);
但它给出了 1000px; 尽管我可以看到 div 的水平滚动条。
我应该怎么做才能实现这一目标?
我可以检查 div 是否出现水平滚动条吗?
任何帮助表示赞赏。
注意:我不想使用任何 Javascript 库。
scrollWidth
, clientWidth
做到了
var mydiv = document.getElementById("grid_print");
if (mydiv.scrollWidth > mydiv.clientWidth){
alert("limit exceeds")
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.