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

  • Home
  • SEARCH
  • 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 9272921
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T15:58:43+00:00 2026-06-18T15:58:43+00:00

I have a well functioning div slider: http://jsfiddle.net/UqSFr/2/ The basic function is this: $(#NextButton).click(function(e)

  • 0

I have a well functioning div slider: http://jsfiddle.net/UqSFr/2/

The basic function is this:

$("#NextButton").click(function(e) { 
e.preventDefault();
if ( $("#h_wrapper").is(':not(:animated)') && $("#NextButton").is(':not(:animated)') ) {
    var newMargin = CurrentMargin() - SlideWidth;
    $("#h_wrapper").animate({ marginLeft: newMargin }, SlideSpeed, function () { SetNavigationDisplay() }); 
}
});

In addition to the click functionality, I want to add a timer so if not clicked in 5 seconds, it should move to the next.

The timer should be reset on click

When the end is reached it must go to the first div (marginLeft = 0)

  • 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-18T15:58:45+00:00Added an answer on June 18, 2026 at 3:58 pm

    Have a look at this code

    $(document).ready(function(e) {
        var index = 0;
        var count = $('#h_wrapper').children().length; // set this value dynamically
    
        var interval = setInterval(next, 1000); // create the interval
    
        // move to next slide
        function next() {
            index = (index + 1) % count;
            goto(index);
        }
    
        // move to previous slide
        function previous() {
            index = (index + count - 1) % count; // not too pretty, but it works
            goto(index);
        }
    
        // go to slide x
        function goto(x) {
            var margin = index * SlideWidth; // set offset by index + width
    
            $('#h_wrapper').stop().animate({ // stop cancels any running animations
                'margin-left': margin
            }, SlideSpeed, function(e) {
                SetNavigationDisplay();
            });
        }
    
        // set click handlers
        $("#NextButton").click(next);
        $("#PreviousButton").click(previous);
    });
    

    It’s pretty easy. By saving the index it’s easier to calculate next and previous offset. Splitting the entire animation into a separate function, the code doesn’t gets easier to read and understand, but easier to call as well.

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

Sidebar

Related Questions

Well i have a div tag that i show as a modal dialog this
I have a well div, and I would like to attach a small text/image
well i have a configuration like this in the components part of my config
I have this scenario well, i'll let the model explain. public class ScheduleMonthlyPerDayModel {
As it stands, I have some JQuery along these lines - ph=function(i){ $.each(i,function(po){ id=po.id;url=/+id;t=$('<div
I'm getting this warning all over the place in some perfectly well functioning objective-c
I have tried to document this as well as I can in the code.
I like to have well defined interface in a few classes, for this I
I have a server running Apache FTPServer. The FTP server is functioning well until
I have created one stored procedure and its functioning well, what I am wanting

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.