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

  • Home
  • SEARCH
  • 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 6360753
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T23:41:21+00:00 2026-05-24T23:41:21+00:00

Markup: <div id=status> <div style=display: block;>Status OK – 16:57:09.</div> <div style=display: block;>Status OK –

  • 0

Markup:

<div id="status">
    <div style="display: block;">Status OK - 16:57:09.</div>
    <div style="display: block;">Status OK - 16:57:09.</div>
    <div style="display: block;">Status OK - 16:57:05.</div>
    <div style="display: block;">Status OK - 16:57:05.</div>
    <div style="display: block;">Status OK - 16:57:03.</div>
    <div>No status yet.</div>
</div>

Using AJAX, I’m adding a new Div to the status div. I only want five divs to be inside at all time. Meaning after the sixth ajax class, the last div should be removed.

Here is my jQuery code:

<script type="text/javascript">
    function Update() {
        PurgeOldStatuses();
        $("#status").children().first().hide().fadeIn();
    }

    function PurgeOldStatuses() {
        // From the status div, find all divs with index after 5, and remove them.
        $("#status").$("div:gt(5)").remove();
    }
</script>

I wrote in a comment to illustrate what I think is going on, perhaps I’m wrong.

Currently not elements are removed. Any suggestions why?

  • 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-05-24T23:41:22+00:00Added an answer on May 24, 2026 at 11:41 pm

    In order to get better performance, avoid proprietary selectors like :gt(), and only use valid CSS selectors.

    This should be very quick:

    $("#status").find("div").slice(5).remove();
    

    or this:

    $("#status div").slice(5).remove();
    

    From the docs for the gt-selector[docs]:

    Because :gt() is a jQuery extension and not part of the CSS specification, queries using :gt() cannot take advantage of the performance boost provided by the native DOM querySelectorAll() method. For better performance in modern browsers, use $("your-pure-css-selector").slice(index) instead.

    Note that the docs recommend using the slice()[docs] method, which grabs all elements in the set starting at the zero-based index you provide.

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

Sidebar

Related Questions

Markup: <div class=foo> <img src=loading.gif class=loading style=display: none; /> </div> Js: $(div[class='foo']).click(function(e) { e.preventDefault();
Suppose I have the following DIV <div id=myDiv style=display:none title=></div> I have an ajax
I have the fallowing markup: <div class=container> <div style=display:none>1</div> <div style=display:none>2</div> <div style=display:none>3</div> </div>
I want this markup: <div style=background:url('Untitled.jpg');height:50px;width:50px;></div> to behave as this markup: <img src=untitled.jpg width=50
I have the following markup: <div style=overflow:auto;width:500px;height:100px;> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li>
I'm using Ajax to dynamically populate a DIV. I have each page content stored
My markup looks like: <div class=c1> <li class=c2><a href=>blah</a></li> </div> I want the text
I'm attempting to parse some Wiki-style markup using the Javascript Creole Wiki Markup Parser
I have this markup: <div class=myToggledDiv> <div>content</div> </div> <div style=margin-top: 10px;> content </div> Via
My markup is a simple div element with id 'load'. Using jQuery I then

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.