如何获取内联CSS溢出y的Scrolltop()值:自动效果

时间:2018-07-05 04:48:49

标签: javascript jquery

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();

1 个答案:

答案 0 :(得分:0)

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 .