Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8318883
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T22:07:54+00:00 2026-06-08T22:07:54+00:00

Here’s an example, to explain what I’m trying to achieve Jimmy: Hey I’m a

  • 0

Here’s an example, to explain what I’m trying to achieve


Jimmy: Hey I’m a new message sent from PHP, I’m new and I’m appended onto the message log :)!

Tommy: Hey you! More of us messages are coming, your gonna be removed soon!

Jonny: Right that’s it only one more message till Jimmy gets removed because he’s knocked out of our box(div).

10 seconds later…

Tommy: Hey you! More of us messages are coming, your gonna be removed soon!

Jonny: Right that’s it only one more message till Jimmy gets removed because he’s knocked out.

Billy: HI GUYS! .. Wait where’d jimmy go?

Jonny: The box became too full, so one of us had to go, Jimmy was at the top,so off he went. Speaking of which, there’s goes Tommy! Tommy gets removed.


Using a setInterval, I managed to achieve a similar effect however, it would only remove the BOTTOM one overflown, which was the newest one instead of the top one who’s message was “old”.

here’s the code I created to achieve this…

var message=document.getElementById('chat_wrap');

if(message.scrollHeight>message.offsetHeight) {
Element.remove();
}

So basically, I want the reverse of what I’ve done. But I’m not sure how I could achieve this.


update to make it more clear:


Sorry, my explanation isn’t that clear. A good example would be a waterbottle, when it gets full remove the water from the bottom, instead of removing it from the top. Another way to explain what I’m trying to achieve is basically the NEWEST is the priority, so if the newest needs space in the div then remove the oldest one still standing.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T22:07:56+00:00Added an answer on June 8, 2026 at 10:07 pm

    Here is a working example.

    http://jsfiddle.net/JNahf/2/

    <div id="messages">
    </div>
    <button id="insertAMessage">Insert a message</button>
    

    script

    $(function(){
        var removeOldest = function(){
            var messages = $("#messages");
            var maxHeight = messages.height();
            var height = 0;
    
            $(messages.children().get().reverse()).each(function(){
                height += $(this).height();
                if (height > maxHeight)
                   $(this).remove();
            });
        };
    
    
        $("#insertAMessage").click(function(){
           $('<div class=".messageItem">bla bla bla bla</div>').appendTo("#messages");
           removeOldest();
       });
    });​
    

    I’m using jquery because it’s simple. If you’re not using jquery the idea is the same, but you will need to adapt the code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Here is what I am trying to achieve in PHP: I have this string:
Here is the code in a function I'm trying to revise. This example works
Here's the code require_once 'functions.php'; require_once 'cfg.php'; $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $db);
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
Here I am trying to retrieve the response from the server and display it,
Here is what I am currently doing. PHP echo's out the recent post in
Here is the script I'm using, copied directly from Google: <script type=text/javascript> var _gaq
Here is an example. foreach (var doc in documents) { var processor = this.factory.Create();
Here is an example: I write html code inside of textarea, then I swap
Here's what I'm trying to accomplish with this program: a recursive method that checks

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.