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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T17:47:49+00:00 2026-06-18T17:47:49+00:00

I have a slider that I’ve built myself, which is a carousel that infinitely

  • 0

I have a slider that I’ve built myself, which is a carousel that infinitely loops. I’m wanting to create a counter (1 of 4, 2 of 4) etc, with the last number being the total number of slides present and the 1/2/3/4 displays which slide you are viewing.

This is what I have so far for my counter:

var $tota = $('.past-project-container').find('span.total');
var $curr = $('.past-project-container').find('span.current');

function changeCurr(){
    $tota.text(numberOfProjects);
    $curr.text(1);
}
    changeCurr();

HTML:

<span class="slide-count-container">
   <span class="current">1</span> of <span class="total">1</span>
</span>

And this is my JS for the carousel if it helps

var $carousel = $('.past-project-slider'), carW = $carousel.outerWidth(), intv;
$carousel.wrapInner('<div id="slider" />');
var $slider = $('#slider');
numberOfProjects = $('.past-project-each').length;
$slider.css({position:'absolute',left:0, width:carW*numberOfProjects}).find('.past-project-each').css({'float':'left'});

function move(cb){
  if(!$slider.is(':animated')){
    if(cb=='next'){
        $slider.animate({left:-carW},800,function(){
            $slider.append($('.past-project-each:first'));
            $slider.css({left:0});
        });    
    }else{
        $slider.prepend($('.past-project-each:last'));
        $slider.css({left:-carW});
        $slider.animate({left:0},800); 
    }
  }
}

$('#next-past-project, #prev-past-project').click(function(){  
    var btn = this.id=='next-past-project' ? move('next') : move('prev');  
});

Many thanks,
R

  • 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-18T17:47:50+00:00Added an answer on June 18, 2026 at 5:47 pm

    Rather than constantly reading and converting the contents of the $curr element its probably better to keep track in another variable, like so:

    var $tota = $('.past-project-container').find('span.total');
    var $curr = $('.past-project-container').find('span.current');
    
    var currentIndex = 0;
    
    function changeCurr(){
        $tota.text(numberOfProjects);
    
        // If we've not reached the final index, add one, else return to the start
        currentIndex = (currentIndex == numberOfProjects) ? 1 : currentIndex + 1;
        $curr.text(currentIndex);
    }
    
    changeCurr();
    

    This will count up until the last slide. Be sure to call changeCurr() on each slide transition.

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

Sidebar

Related Questions

I have an image slider that I built for my website, and I have
I have built a slider that has two possible buttons: one to .toggle ,
I built an image slider that uses jquery to create a loop of images.
I have a jquery slider that I have built, basically just three pannels that
I have a slider that has a fade-in and fade-out transition. It basically cycles
I have a slider that returns values from 0.0f to 1.0f. I want to
I have a StackPanel inside of a ScrollViewer. I have a slider that does
I have an SVG slider that I've been working on ... please see it
I have this complicated slider that utilizes tons of animation. I'm trying to find
I have Slider in my app that is connected to a few methods. In

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.