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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T08:10:22+00:00 2026-06-10T08:10:22+00:00

Please i need help sliding images using jquery back and forth, or just to

  • 0

Please i need help sliding images using jquery back and forth, or just to go round. right now it slides upto the last element and rushes back to the first div and begins again, not beautiful at all,i know i should call back a function to do that but i keep getting mistakes. thanks in advance, this is my jquery code below

$(document).ready(function() {
    var currentPosition = 0;
    var slideWidth = 190;
    var slides = $('.slider_move');
    var numberOfSlides = slides.length;
    var slideShowInterval;
    var speed = 5000;

    slideShowInterval = setInterval(changePosition, speed);                 
    slides.wrapAll('<div id="slidesHolder"></div>')                 
    slides.css({ 'float' : 'left' });                   
    $('#slidesHolder').css('width', slideWidth * numberOfSlides);  

    function changePosition() {
        if(currentPosition == numberOfSlides - 1) {
            currentPosition = 0;
        } else {
            currentPosition++;
        }
        moveSlide();
    }                   
    function moveSlide() {
            $('#slidesHolder')
              .animate({'marginLeft' : slideWidth*(-currentPosition)});
    }
});​
  • 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-10T08:10:24+00:00Added an answer on June 10, 2026 at 8:10 am

    Instead of:

    if(currentPosition == numberOfSlides - 1) {
        currentPosition = 0;
    } else {
        currentPosition++;
    }
    

    You need to move the first slide to the very end (and adjust the position of the container at the same time):

    if (currentPosition > 0) {
        $('#slidesHolder').css('marginLeft',0)
            .children().first().appendTo('#slidesHolder');
    } else {
        currentPosition += 1;
    }
    

    http://jsfiddle.net/mblase75/qatry/

    Or, to optimize the whole thing a little more, you can eliminate the currentPosition variable and the moveSlide sub-function, and just use a callback in the .animate method:

    function changePosition() {
        $('#slidesHolder').animate({
            'marginLeft': 0-slideWidth
        }, function() {
            $('#slidesHolder').css('marginLeft', 0)
                .children().first().appendTo('#slidesHolder');
        });
    }
    

    http://jsfiddle.net/mblase75/8vaCg/

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

Sidebar

Related Questions

I need some help to get this right, please. I have created an iPad
I'm still learning Haskell and need help with the type inference please! Using packages
I will need a Jquery script for a table sliding effect just like http://sfsdirectdemo.projects.sourceflow.com/luke
just need help with regular expression in mysql query please: column ISRC GBCQV0700378 GBCQV0700382
Please i need your help with a small issue i'm having. I'm using the
Please i need help, this code below works fine on my localhost, php5.3+ but
Please I need your help with grabbing rows from a table and dynamic text
please i need you help with my script.. I'm trying to echo some content
Please I need your help with my script. I'm trying to insert values into
Please i need your help with how to include INDEXES in my tables, i've

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.