javascript - 如何获取内联 css 溢出-y:自动效果的 Scrolltop() 值
问题描述
div 看起来像这样
<div class="nestedDemo" ng-include="'test.html'" style="height: 500px;
overflow-y: auto;"></div>
我想获取此 div 的 scrolltop 值,因为在将其他 div 添加到它(拖放功能)后,该 div 具有滚动条。
Js 代码看起来是这样的,但是即使有可用的滚动条,scrollValue 的值也始终为 0。
var scrollValue = $('.nestedDemo').scrollTop();
解决方案
var scrollValue = $('.nestedDemo').scrollTop();
//the value is never change;
//when the div has scrollbar after adding other div's to it(drag-drop function).
//you need get the value once again.
// if you remove a children , get the value once again .
推荐阅读
- bash - bash 脚本以递归方式检查包含两个特定文件的文件夹并打印它们的路径
- apache-spark - spark-submit 不适用于我位于 hdfs 中的 jar
- html - 打印时需要控制表格列的宽度
- php - 使用会话时如何修复未定义的索引错误
- kubernetes - 部署 Yaml 中的 Google Cloud Kubernetes Persistent Volume Claim 错误
- iis - 继续获取 Unauthorize Web API
- swift - 如何在 Swift 中从 Error 转换为 CFError?
- javascript - 未捕获的类型错误:使用 Rcipe API 时无法读取未定义的属性“地图”
- javascript - 创建一个过渡模板以供重复使用
- android - 将 xml 文件添加到其存储位置后如何刷新 SharedPreferences