Note that there are some explanatory texts on larger screens.

plurals
  1. POjQuery empty()/remove() makes page jump
    text
    copied!<p>I have a monitoring website which shows "who is logged in" and their "state" (online/away/etc.).</p> <p>They are basically wrapped near the bottom of my page with:</p> <pre><code>&lt;table cellpadding="0" cellspacing="0" id="telecaster_agentenstatus" class="telecaster"&gt; &lt;tr&gt; &lt;td id="free_agents"&gt; &lt;/td&gt; &lt;td id="acw_agents"&gt; &lt;/td&gt; &lt;td id="pause_agents"&gt; &lt;/td&gt; &lt;/tr&gt; &lt;tr id="telecaster_agentenstatus_start"&gt; &lt;td id="agentenstatuus" colspan="3"&gt; &lt;div class="agent_telecaster_container"&gt;&lt;/div&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; </code></pre> <p>So all "agents" get into the div with the class "agent_telecaster_container". I append as many divs as I need with:</p> <pre><code>for (nameAgent in supervisionagents.group[0].agent) { //$("#agentenstatuus").append('&lt;div class="agent_telecaster"&gt;'+nameAgent+'&lt;/div&gt;'); counter++; if (supervisionagents.group[0].agent[nameAgent].stateCurrent.description == "idle") { $(".agent_telecaster_container").append('&lt;div id="agent'+counter+'" class="agent_telecaster"&gt;&lt;img src="images/icons/box_green_12x12.png"&gt;&amp;nbsp;' + nameAgent + '&lt;/div&gt;'); } </code></pre> <p>Which gets called over and over again.</p> <p>What I need is to "clear" the with its content because it can be that every second someone gets offline or online.</p> <p>So far this can be possible with a simple:</p> <pre><code>$('.agent_telecaster_container').empty() / .remove(); </code></pre> <p>But what then happens is that if I move my view / scrollbar to view some things underneath that table, with every reload (every sec.) it jumps back to this . I guess this happens because of the remove / empty and this element gets deleted but new content gets in.</p> <p>Has anybody any idea on how to prevent the jumping? :/</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload