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 6674965
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:47:42+00:00 2026-05-26T03:47:42+00:00

I’m trying to program something like facebook recent update part,so I program following code

  • 0

I’m trying to program something like facebook recent update part,so I program following code by jQuery and JavaScript

<script type="text/javascript">
var time ='<?php echo (time()); ?>';
time = 0;// remove later
var counter = 0;
var profile_url = '<?php echo (base_url()); ?>index.php/profile/';
var base_get_update_url = '<?php echo (base_url()); ?>index.php/pro_ajax/last_update/';
function get_update()
{
    var get_update_url = base_get_update_url + time;
    $.getJSON(get_update_url,function(data){
      var count_result = data[0].length + data[1].length + data[2].length + data[3].length;

       var update =  $("#UpDate").children();
        if ((update.length != 0) && (update.length + count_result) >= 15)
       {

           for (var i = 0;i < (update.length + count_result) && i < update.length;i++)
               {
                   update =  $("#UpDate").children();
                   update.last().remove();
               }
       }

      for (var i = 0;i < data[0].length;i++)
          {
              $("#UpDate").prepend('<li><a href="'+profile_url+data[0][i][1]+'">'+data[0][i][0]+'<hr /></a></li>');
          }

      for (var i = 0;i < data[1].length;i++)
          {
              $("#UpDate").prepend('<li><a href="'+profile_url+data[1][i][1]+'">'+data[1][i][0]+'<hr /></a></li>');
          }
      for (var i = 0;i < data[2].length;i++)
          {
              $("#UpDate").prepend('<li><a href="'+profile_url+data[2][i][1]+'">'+data[2][i][0]+'<hr /></li>');
          }
      for (var i = 0;i < data[3].length;i++)
          {
              $("#UpDate").prepend('<li><a href="'+profile_url+data[3][i][1]+'">'+data[3][i][0]+'<hr /></a></li>');
          }

    });
}
setInterval("get_update()", 5000);

it will get last update and show them successfully,but It can’t remove child.
I try to do if new element + before element is more than 15,it should remove some of first element.but it can’t do it.why?
(following code will show UpDate part) :

<td style="width: 200px;text-align: left;border: 2px solid white" id="UpDate"></td>
  • 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-26T03:47:42+00:00Added an answer on May 26, 2026 at 3:47 am

    Removing elements can be implemented in a much simpler way. Consider using the .slice() method, which allows you to select a subset of the selected elements, so you could remove some children of the #UpDate element with the following call:

    $('#UpDate').children().slice(0, n).remove();
    

    (n is the number of child elements that you want to remove)

    As a side note, you seem to be adding <li> elements to a <td> element, which is not valid HTML.

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

Sidebar

Related Questions

I ran into a problem. Wrote the following code snippet: teksti = teksti.Trim() teksti
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I've got a string that has curly quotes in it. I'd like to replace
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I am trying to loop through a bunch of documents I have to put

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.