0
所以我有流動的HTML:jQuery的scrollTop的不隨高度和滾動條的HTML元素的工作
<div class="textconvo col-md-10 col-md-offset-1">
<div class="row sender">
<div class="col-sm-3">
Heather Harris
</div>
<div class="col-sm-6">
sun
</div>
<div class="col-sm-2">
11/21/2014 6:58 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
dfgdfgdfgdfg
</div>
<div class="col-sm-2">
11/21/2014 8:31 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
assdfsdfsdf
</div>
<div class="col-sm-2">
11/21/2014 8:57 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
sdfsdfsdf
</div>
<div class="col-sm-2">
11/21/2014 8:58 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
sdfsdfsdf
</div>
<div class="col-sm-2">
11/21/2014 8:58 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
sdfsdfsdfsdf
</div>
<div class="col-sm-2">
11/21/2014 8:58 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
sdfsdfsdf
</div>
<div class="col-sm-2">
11/21/2014 8:58 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
sdsdf
</div>
<div class="col-sm-2">
11/21/2014 9:06 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
sdfsdfsdf
</div>
<div class="col-sm-2">
11/21/2014 9:06 PM
</div>
</div>
<div class="row">
<div class="col-sm-3">
robert
</div>
<div class="col-sm-6">
fdgdfgdfg
</div>
<div class="col-sm-2">
11/21/2014 9:31 PM
</div>
</div>
<div style="display: none;" id="newMessagePlaceHolder-3665048123427363225"></div>
</div>
而且這個CSS:
.textconvo
{
overflow-y: scroll;
-ms-overflow-y: scroll;
height: 300px;
}
而且這個jQuery的文件調用。準備:
$('.textconvo').each(function() {
$(this).scrollTop($(this)[0].scrollHeight); //scrollHeight = 0
$(this).scrollTop(500); //this doesn't work either
});
我在其他應用程序做過scrollTop的,它已先後在div.textconvo在DOM。
有什麼建議嗎?
頁面上有任何錯誤嗎?檢查你的調試輸出 – 2014-11-22 20:05:41