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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T10:02:07+00:00 2026-05-31T10:02:07+00:00

How can I make pagination in my carousel, sometimes they’re in dots, numbers, etc.

  • 0

How can I make pagination in my carousel, sometimes they’re in dots, numbers, etc. I want them to link the their appropriate slide-item. So for example if I click number 3, then the 3rd slide-item should slide to the viewport and so on. No plugin please, as I’m learning how to write javascript.

JS:

var panelsList = $('.panels'),
    panel = panelsList.find('li'),
    panelWidth = panel.outerWidth(true),
    panelsNum = panel.length,
    controls = $('.controls'),
    currPanel = panelsList.find('li:first-child');

panelsList.width( panelWidth * panelsNum );

// controls 
controls.on('click', 'a[data-target]', function(e){
   var self = $(this),
       selfPos = self.index(),
       self_href = $(self.attr('href')),
       self_href_pos = self_href.index();

   e.preventDefault();

   /** slide the corresponding item to viewport: 
    * this is where I'm stuck... I don't know what to do
    */
   self_href.parent().animate({ marginLeft: '-=' + self_href_pos * panelWidth + 'px' });

   panel.removeClass('active');
   self_href.addClass('active');

});

HTML:

<!-- carousel -->
<div class="carousel">
    <div class="fenetre">
        <ul class="panels">
            <li id="one">1</li>
            <li id="two">2</li>
            <li id="three">3</li>
            <li id="four">4</li>
            <li id="five">5</li>
        </ul>
    </div>

    <!-- controls -->
    <ul class="controls">
        <li><a href="#" class="prev">prev</a></li>
        <li><a href="#one" data-target="one">1</a></li>
        <li><a href="#two" data-target="two">2</a></li>
        <li><a href="#three" data-target="three">3</a></li>
        <li><a href="#four" data-target="four">4</a></li>
        <li><a href="#five" data-target="five">5</a></li>
        <li class="last"><a href="#" class="next">next</a></li>
    </ul>
    <!-- controls -->
</div>
<!-- carousel -->

CSS:

.fenetre {
    width: 866px;
    background: #9BBBC7;
    border: 1px solid #555;
    overflow: hidden;
}

.panels li {
    border: 1px solid #777;
    background: #E0D1CC;
    color: #555;
    float: left;
    font-size: 46pt;
    font-weight: bold;
    height: 333px;
    width: 864px;
}

/** CONTROLS */
.controls {
    margin-top: 20px;
    margin-left: 125px;
}
.controls li {
    background: #E0D1CC;
    border: 1px solid #777;
    float: left;
    margin-right: 20px;
    text-align: center;
    width: 70px;
}

.controls li a {
    color: #555;
    display: block;
    padding: 5px;
    text-decoration: none;
}

Many 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-31T10:02:08+00:00Added an answer on May 31, 2026 at 10:02 am

    I moved your code around a tiny bit:
    http://jsfiddle.net/bew6Z/
    I hope it’s what you were going for

    // controls
    controls.on('click', 'a[data-target]', function(e) {
    
        var self = $(this),
            selfPos = self.index(),
            self_href = $(self).attr('href'),
            self_href_pos = $(self_href).index(),
            scroll_position = self_href_pos * panelWidth;
    
        e.preventDefault();
        console.log(self, selfPos, self_href, self_href_pos, scroll_position);
    
        /** slide the corresponding item to viewport:
         * this is where I'm stuck... I don't know what to do
         */
    
        $(self_href).parents('.carousel').animate({
            scrollLeft: scroll_position
        }, 1000);
    
        panel.removeClass('active');
        $(self_href).addClass('active');
    
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

How can make a link within a facebox window that redirects it to another
I want to make a minimalistic pagination script that basically does three things: On
At: http://nathansearles.com/loopedslider/example-4.html , the pagination actually has numbers in it (you can see this
I can make my program write a .dat file with an array of Node
I can make a single row IKImageBrowserView by setting the [imageBrowser setContentResizingMask:NSViewWidthSizable]; but in
I can make a variable's name from two variables' value: $a = 'tea'; $b
I can make a log in for easily, so that's not the problem. What
I can make batch or vbs file on windows and run. this can automate
Can someone tell me how I can make a table be 100% height in
Can someone tell me how I can make the following output? I have a

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.