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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T20:18:55+00:00 2026-05-14T20:18:55+00:00

This is the (quite simple) JS code I’m using: $(document).ready(function() { $(.button-list .next).click(function() {

  • 0

This is the (quite simple) JS code I’m using:

    $(document).ready(function() {
        $(".button-list .next").click(function() {
            project = $(this).parents().filter(".projektweb").eq(0);
            currentimg = project.find(".images-list li.current");
            nextimg = currentimg.next();
            firstimg = project.find(".images-list li:first");
            currentimg.removeClass("current");
            if (nextimg.is("li")) nextimg.addClass("current");
            else firstimg.addClass("current");
            return false;
        });
        $(".button-list .prev").click(function() {
            project = $(this).parents().filter(".projektweb").eq(0);
            currentimg = project.find(".images-list li.current");
            previmg = currentimg.prev();
            lastimg = project.find(".images-list li:last");
            currentimg.removeClass("current");
            if (previmg.is("li")) previmg.addClass("current");
            else lastimg.addClass("current");
            return false;
        });
    });

And this is how the HTML code for the image list looks like:

<ul class="images-list">
    <li class="current"><img src="img/1.jpg" alt="" /></li>
    <li><img src="img/1b.jpg" alt="" /></li>
</ul>

<ul class="button-list"> <li><a class="button prev" href="#">←</a></li> 
<li><a class="button next" href="#">→</a></li></ul>

The CSS:

.images-list {
    height: 460px;
    list-style-type:none;
    float:left;
    width: 460px;
    overflow:hidden;
    position:relative;
}

.images-list img {
    height: 460px;
    width: 460px;
    display:block;
}

 .images-list li {
    display:none;
}

.images-list li.current {
    display:block;
}

What I’d like to do is animate the images as they come and go – right now they just appear, which is OK but a bit more eye-candy would be nice.

Can anyone help me out here? It it even possible to do it this way? Thanks!!

  • 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-14T20:18:56+00:00Added an answer on May 14, 2026 at 8:18 pm

    I made a demo for you. Basically I added some left and right scrolling animation using jQuery’s animate()

    You can animate the image in any direction, but if you want to get more fancy, then I would use the Cycle plugin as Matt suggested.

    Additional CSS

    .images-list li.animating {
     position: absolute;
     top: 0;
     left: 0;
     display: block;
    }
    

    Script

    $(document).ready(function() {
    
     // *** Constants ***
     var project = $('.projektweb');
         animationTime = 500,  // scroll time in milliseconds
         animationWidth = 480; // image width = 460 + 20px padding between images
         leftPadding = parseInt( project.find('ul').css('padding-left'), 10); // padding due to UL
    
     // *** Next image ***
     $('.button-list .next').click(function() {
      currentimg = project.find('li.current');
      nextimg = (currentimg.next().is('li')) ? currentimg.next() : project.find('.images-list li:first');
    
      currentimg
       .removeClass('current')
       .addClass('animating')
       .css('left', leftPadding)
       .animate({
        left: '-=' + animationWidth 
       }, animationTime, function(){
        $(this).removeClass('animating');
       });
    
      nextimg
       .addClass('animating')
       .css('left', (animationWidth + leftPadding) + 'px')
       .animate({
        left: 0 + leftPadding
       }, animationTime, function(){
        $(this).removeClass('animating').addClass('current');
       })
    
      return false;
     });
    
     // *** Prev image ***
     $('.button-list .prev').click(function() {
      currentimg = project.find('.images-list li.current');
      previmg = (currentimg.prev().is("li")) ? currentimg.prev() : project.find('.images-list li:last');
    
      currentimg
       .addClass('animating')
       .css('left', leftPadding)
       .removeClass("current")
       .animate({
        left: '+=' + animationWidth
       }, animationTime, function(){
        $(this).removeClass('animating');
       });
    
      previmg
       .addClass('animating')
       .css('left',  '-' + (animationWidth) + 'px')
       .animate({
        left: '+=' + (animationWidth + leftPadding)
       }, animationTime, function(){
        $(this).removeClass('animating').addClass('current');
       })
    
      return 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 set a callback function in Jack. This is usually quite simple,
This should be quite simple but I can`t fix it :/ I am using
Why does this quite simple xquery takes 10min to execute in sql server (the
This is quite a simple question - although one that is on my mind
This should be quite simple, but I can't work out the syntax. I have
This is probably quite simple, but I just don't know how to do this...
This must be quite simple but I can't seem to figure this out. I've
This task should be quite simple, but nothing I tried has worked. I'm just
This is probably a really simple question but one I've never quite worked out
This might be a simple question for some people since it was quite hard

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.