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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T06:14:39+00:00 2026-06-15T06:14:39+00:00

Ok firstly – its not a toggle() as such. This code is supposed to

  • 0

Ok firstly – its not a toggle() as such.

This code is supposed to work like a slider. 1 Div is showing, you click a button, and the next div shows, click another button, and the first div shows.

This works so far, but it doesn’t work going backwards. So the button works to show the 2nd Div, but hitting the ‘less’ button I made just makes the second div disappear and the 1st remains hidden.

Here is the code:

$('.more').click(function() {
    $('.c1')
        .animate({ left: "-828px" }, 600, 'easeInOutQuint')
        .delay(300, function() {
            $('.c2').animate({ left: "0px" }, 600, 'easeInOutQuint'); 
        }
    );
});

$('.less').click(function() {
    $('.c2')
        .animate({ left: "828px" }, 600, 'easeInOutQuint')
        .delay(300, function(){
            $('.c1').animate({ left: "0px" }, 600, 'easeInOutQuint'); 
        }
    );
});

What am I missing? And how could I do this so that I’m basically not repeating the same code twice?

  • 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-15T06:14:41+00:00Added an answer on June 15, 2026 at 6:14 am

    You have a wrong concept about .delay.

    In jquery documentation:

    Description: Set a timer to delay execution of subsequent items in the queue.

    And its parameters are: duration [, queueName].

    Also, from SO answer:

    The delay() function only applies to actions queued on the element

    So I think your best choice is, as @nicolast said, use the callbacks. Here it is working. And the final code is:

    $('.more').click(function() {
        $('.c1')
            .animate({ left: "-400px" }, 600, function() {
                $('.c2').animate({ left: "0px" }, 600);
            }
        );
    });
    
    $('.less').click(function() {
        $('.c2')
            .animate({ left: "400px" }, 600, function(){
                $('.c1').animate({ left: "0px" }, 600);
            }
        );
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Firstly, I wrote my customized setter for an NSString* like this: - (void)setDateString:(NSString *)newDateString
Firstly, this is going to sound like homework, but it ain't. Just a problem
Firstly, I'm not using rails. This is vanilla ruby application. I've read about packaging
Firstly, I'd like to show you a piece of code. The code is a
Firstly, very sorry if this is not a true stackoverflow question. But it's something
Firstly appologies for the poor title, not sure how to explain this in one
Firstly I have a class signature that looks like this: internal class JobStore :
Firstly, this is not a question about repository synchronisation for which there are numerous
Firstly, is it safe to mix green threads such as eventlet or gevent with
Firstly sorry if this is a common question but I couldn't find anything on

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.