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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T16:07:07+00:00 2026-05-23T16:07:07+00:00

I am using jQuery .animate method to animate a stack of cards. Assuming these

  • 0

I am using jQuery .animate method to animate a stack of cards.
Assuming these are the four cards visually displayed [#card1][#card2][#card3][#card4][#card5]

Their div tags , #card1 , #card2, #card3 , #card4 are stored in an array cardStack()
Now i want to animate each of these on click, one after the other when you click them.
So can i do something like

while(cardStack[0]!="undefined"){
    $('#cardStack[0]').click(function() {    
    $('#cardStack[0]').animate({"left": "+=130px","z-index": "1",queue:false},500);
});
i--;
}

is this possible ?

  • 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-23T16:07:07+00:00Added an answer on May 23, 2026 at 4:07 pm

    I’ll annotate the source, so that you could actually learn something:

    Save the reference to the array of cards.

    var cards = $('#cards div');
    

    The first flipped card will be outside our array.

    var flippedIndex = cards.length;
    

    Next, we create an array (with the same length as the cards array), containing information on which cards are flipped.

    var flipped = new Array(flippedIndex);
    

    The flip function animates and changes the class attribute of a card.

    var flip = function (card, toggle) {
        card.slideUp(function () {
            card.toggleClass('back', toggle)
                .slideDown();
        });
    };
    

    Now we set the click listener.

    cards.click(function () {
        var card = $(this),
    

    .index() (http://api.jquery.com/index/) gives you the position of the card from left to right.

        index = card.index();
    

    Lookup our flipped array to see if the card is flipped and check that it’s the last card flipped.

    if (!flipped[index] && index + 1 === flippedIndex) {
            flippedIndex = index;
    

    Here we flip the card.

        flip(card, (flipped[index] = true));
    } else if (flipped[index] && index === flippedIndex) {
        flippedIndex++;
    

    Here we unflip it.

           flip(card, (flipped[index] = false));
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to animate a block level element using jQuery. The page loads with
I am trying to find a way to animate a div using jQuery to
I want to use .animate to change colors when .bind('click') is fired, using jquery
I'm using this jQuery to hide a DIV: $(#slider).click(function() { $(.help).slideToggle(); $(#wrapper).animate({ opacity: 1.0
I'm using JQUERY animate to show a banner at the top of the page,
I seem to be having difficulties using jQuery .animate() to animate an absolutely positioned
I'm using jquery to animate a bit my web site, but I'm having a
I'm using jQuery's animate function like this: var css1 = { display: block, marginTop:
how can I animate the background-position property using jQuery's animate function without using a
I am wondering if it is possible to animate background url using jQuery, and

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.