Can you please tell me how to remove the div content? I am getting data from server regularly. I check if div height is "100" .
Then it remove content and write data from top in jQuery. I tried very thing nothing is working for me.
var scrollerDivHeight=$('#scroller').height();
if(scrollerDivHeight==100){
// $('#scroller').val()='';
$('#scroller' ).innerHTML = '';
$("#scroller").empty();
$('#scroller').val('');
$('#scroller').html('');
$('#scroller').refresh();
myScroll.refresh();
}
Us the Empty() method in jquery
setInterval(function () {
$('#realtime').append("Hiiiii. is div").css("line-height", "100px");
var scrollerDivHeight=$('#realtime').height();
if(scrollerDivHeight>100){
$("#realtime").empty();
}
}, 1000);
See fiddle Demo
Read Jquery Empty Documentation here
You can try replacing this with your code
var scrollerDivHeight=$('#scroller').height();
if(scrollerDivHeight >= 100){
$('#scroller').replaceWith('<div id="scroller"></div>');
}
Use > not == also fix the id
setInterval(function () {
$('#scroller').append("Hiiiii. is div").css("line-height", "100px");
var scrollerDivHeight=$('#scroller').height();
//alert(scrollerDivHeight)
console.log(scrollerDivHeight)
if(scrollerDivHeight>100){
$("#scroller").empty();
}
}, 1000);
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.