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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T19:33:43+00:00 2026-06-07T19:33:43+00:00

I seem to have a very basic problem which I cannot get my head

  • 0

I seem to have a very basic problem which I cannot get my head around and I hope someone will be able to help me…

I have a ‘wrapper’ div with three ‘page’ divs in it. When the rightmost div is clicked this one should become the middle one. I found a nice way to do this by first cloning the first child div and appending it at the end, then animating the ‘wrapper’ div left, then removing the original first child div and restore the ‘wrapper’ div’s original position.

But the problem is that this only works on the first click in the original DOM; that is, it doesn’t recognise the appended div as a new last-child…. can anyone help me out?

Jquery

$(document).ready(function() {
            $('#wrapper div:last-child').click(function() {
                $('#wrapper').animate({'left' : '-33%' }, 500, function() {
                    $('#wrapper div:first-child').clone(true).appendTo('#wrapper');
                    $('#wrapper div:first-child').remove();
                    $('#wrapper').css('left', '0');
                });
            });
        });

HTML

    <div id="wrapper">
        <div class="page" id="p1">1st</div>
        <div class="page" id="p2">2nd</div>
        <div class="page" id="p3">3rd</div>
    </div>
  • 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-07T19:33:44+00:00Added an answer on June 7, 2026 at 7:33 pm
    $('#wrapper').on('click', 'div:last-child', function() {
        $('#wrapper').animate({
            'left': '-33%'
        }, 500, function() {
            $('#wrapper div:first-child').clone(true).appendTo('#wrapper');
            $('#wrapper div:first-child').remove();
            $('#wrapper').css('left', '0');
        });
    });
    

    As you’re adding the div to #wrapper dynamically, so you need delegate event handler. Using jQuery .on() you can bind click like above.

    Syntax of .on() for delegate event is:

    $( staticParent ).on( eventName, targetChild, handler);
    

    Where, staticParent refers to container of target element(dynamic element) which is not dynamic.

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

Sidebar

Related Questions

I have a very simple C# DataTable problem that I cannot seem to wrap
I have a very simple question for which I can't seem to find an
I have a very simple problem, but I can't seem to solve it. I
I have a very big problem and can't seem to find anybody else on
Hi I have run into a very weird problem. I have a basic chrome
I have a question that could seem very basic, but it is in a
This may seem a very silly question. Consider this: I have a simple Boolean
I seem to have a problem with getting MVC to fill in my custom
I seem to have the exact opposite problem than this question on stopping dock
I seem to have a problem understanding how to conditionally test a boolean value

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.