我正在从服务器获取数据(定期)。我需要在每一行前面显示一些文本。所以我认为如果高度发生变化,那么我会在前面的 div 中附加数据。但它不起作用,因为有时大量数据来自服务器(意味着两三行来一次)高度发生了变化。但它只附加一次。
所以我的结果看起来像这样
Text Server data
changed Hiiiii. is i am checking this in the div
please check me also and everty thing is
fine well know dive sdsfdsfsdfdfsdfdsfdsfsd
changed Hiiiii. is i am checking this in the div
please check me also and everty thing is
fine well know dive sdsfdsfsdfdfsdfdsfdsfsd
但我需要我的结果看起来像这样
Text Server data
changed Hiiiii. is i am checking this in the div
changed please check me also and everty thing is
changed fine well know dive sdsfdsfsdfdfsdfdsfdsfsd
changed Hiiiii. is i am checking this in the div
changed please check me also and everty thing is
changed fine well know dive sdsfdsfsdfdfsdfdsfdsfsd
我以这种方式尝试。也许我会一次得到100行。但我需要在内容前面显示 100 次文本。
http://jsfiddle.net/naveennsit/dRrnX/
$(function() {
var h = -1;
setInterval(function () {
var newHeight = $('#realTimeContents').append("Hiiiii. is i am checking this in the div please check me also and everty thing is fine well know div").height();
if (h == -1) h = newHeight;
if (h != newHeight) {
h = newHeight;
$('#realTimeContents1').append(" changed ");
//alert("I've changed height");
}
}, 1000);
});