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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T14:53:46+00:00 2026-06-18T14:53:46+00:00

I have a div content, in this div I have several div comment, I’m

  • 0

I have a div “content”, in this div I have several div “comment”, I’m reloading the div “content” every 5 second, and I would like to fadeIn every new comments. For this, every comment has an id which is an integer, so basically what I’m doing is :
I’m saving the id of the last comment in a variable “lastComment”, and when I’m reloading the div “content”, I’m using if($(“.comment”).attr(id) > lastComment) { alert(‘ok’) }

But it doesn’t work, first it reloads the div and instead of saying ‘ok’ straight I need to wait 5 more seconds, here my code :

var lastComment = $('.comment:last').attr('id');
setInterval(function()
{
    $('#content').load('fullscreen.php?image='+$('.imageBig').attr('id')+' #content');
    if($('.comment').attr('id') > lastComment){
        alert('ok');
    }
}, 5000);

please any idea?

  • 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-18T14:53:48+00:00Added an answer on June 18, 2026 at 2:53 pm

    I think there is your jQuery selector problem, in the if condition you should specify last div.comment because var lastComment = $('.comment:last').attr('id'); statement will assign last element once after this setInterval works and new last div comment will changed so alert not works.

    var lastComment = $('.comment:last').attr('id');
    setInterval(function()
    {
        $('#content').load('fullscreen.php?image='+$('.imageBig').attr('id'),function(){
            if($('.comment:last').attr('id') > lastComment){
                alert('ok');
            }
        });
    
    }, 5000);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have several divs like this <div rel=5> Divs content goes here </div> <div
i have my html something like this... <div class = content> <div class =
I have dynamic content in a div called txtresults like this: <div id=txtresults></div> This
I want to parse a html content that have something like this: <div id=sometext>Lorem<br>
I have some HTML that looks like this: <div class=product> Content In Here <div
OK I have backgrounds set up like this: HTML <div id=container> <div id=content> CONTENT
I have a div container which have several images,like this: <div style=width:600px;height:600px;> <img src=
I have several div elements like this: <div class=newsContainer> <div class=deleteBoxIcon> <img alt=Delete src=close_mark.png>
I have a web page consisting of several <div> elements. I would like to
I have this markup: <div id=slider1> <div class=ui-slider ui-slider-horizontal ui-widget ui-widget-content ui-corner-all> <a style=left:

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.