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

The Archive Base Latest Questions

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

i have some div items in div container and i want to animate them

  • 0

i have some div items in div container and i want to animate them continously.

i know how to run my function in endless loop, but there is a problem with selecting first div, animate it and move it to the end after done animation.

my function looks like this:

function MoveItems() {
        $(".container:first").animate(
            {width: "0px"},
            1000,
            function (){ 
                $('.container').append($(this));
                $('.container').remove($(this));
            }
        );
};

what i’m doing wrong? ;/

edit:

You are right about remove, but the animation still is not working.

i think that selector is not working corectly.

my html is:

<div class="container">
<div class="image"><a href=""><img src="img/image001.jpg" /><span>IMAGE001</span></a></div>
<div class="image"><a href=""><img src="img/image002.jpg" /><span>IMAGE002</span></a></div>
<div class="image"><a href=""><img src="img/image003.jpg" /><span>IMAGE003</span></a></div>
  <div class="image"><a href=""><img src="img/image004.jpg" /><span>IMAGE004</span></a></div>
</div>

but after running function MoveItems once there is:

<div class="container" style="width: 0px; overflow: hidden;">
    <div class="image"><a href=""><img src="img/image001.jpg"><span>IMAGE001</span></a></div>
    <div class="image"><a href=""><img src="img/image002.jpg"><span>IMAGE002</span></a></div>
    <div class="image"><a href=""><img src="img/image003.jpg"><span>IMAGE003</span></a></div>
    <div class="image"><a href=""><img src="img/image004.jpg"><span>IMAGE004</span></a></div>
</div>

so the functions is operating on .container not a first child of container. am i here more specific? 🙂

  • 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-21T00:30:42+00:00Added an answer on May 21, 2026 at 12:30 am

    $(".container:first") selects the first .container it finds.

    You want $(".container>div:first")

    You can also “speed up” the final remove/append by operating on parent instead of doing another DOM search for .container:

    var $me = $(this);
    $me.parent().append($me);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to do this: I have a div with item: title, image, some
I have a link which animates some div 's height when its hovered, but
I have a container with tiles (grass, water, etc) and in some of them
I have some html: <body> <h1 id=header></h1> <div id=container> <div id=left> </div> <div id=content>
I have some recursive HTML in the following tree structure: div.item div.content input div.container
I have some simple markup: <table> <tr> <td>Menu Item</td> </tr> </table> <div> <table> <tr>
In my case, i have some div and img tags. I am applying draggable
I have some problems resizing a div with ID mask which I use to
I have some Html like: <div id=adiv> <ul> <li data-id=3>Cat</li> <li data-id=4>Dog</li> </ul> </div>
I have some divs: <div class=A>Target</div> <div class=A B>NotMyTarget</div> <div class=A C>NotMyTarget</div> <div class=A

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.