.onclick turn 3 cards (divs) instead of 1
Hi all,
I am trying to make a solitaire like game. When I click the cards (read: divs) that are stacked on the deck pile, the top card will turn and move to the left. This all works great. I am using the following code:
- var z = 1;
- $('#deck .card.flipped').on('click', function () {
- if (!$(this).hasClass('dropped')) {
- $('.card').removeClass('ui-front');
- $(this)
- .addClass('ui-front')
- .addClass('on-discard-pile')
- .addClass('dropped')
- .css({'z-index': z++})
- .animate({left: '8rem'}, 200)
- .draggable({ disabled: false})
- .removeClass('flipped');
-
- if (!$(this).is(':first-child')) {
- $('.card').removeClass('under-card');
- $(this).next().addClass('under-card');
- } else {
- $('.card').removeClass('under-card');
- }
- }
- });
Now I want not to turn 1 card from the deck when I click it, but the top 3 cards. Also the first top card will move 8rem to the left (using
.animate({left: '8rem'}, 200)
) but the second card should move 10rem to the left en the third and last card 12rem
How can I do this?
I have tried :lt() and stuff but can't get it working