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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T09:18:51+00:00 2026-06-06T09:18:51+00:00

I am a bit of a noob when it comes to JAVA script, I

  • 0

I am a bit of a noob when it comes to JAVA script, I can read it just about.

I have a script for a slideshow gallery with the code below. And it has nav buttons with numbers. This is all fine how ever they start at number 0 – 5 when I need them to start at 1 -6 .
I have found the code which sets this and it uses an ‘+index+’ option which I guess just counts up from 0. How do I set this to start at 1 not 0? I tried +index+1, & (+1) and a few other in line but it stops it working.
Code below…

if(pager.length) {
    pager.eq(current).addClass('active');
} else if(o.pager){
    obj.append('<ul class="bbpager"></ul>');
    slides.each(function(index) {
    $('.bbpager', obj).append('<li class="pagerButton"><a href="#">
                         <span>'+index+'</span></a></li>')
    });
    pager = $('.bbpager li', obj);
    pager.eq(current).addClass('active');
}

And I tried to add just var index = 1; also below

if ( index === null){
     index = 1 localStorage.setItem("index",index); 
}

Never worked. any idea how i can +1 to the outputted labels?

  • 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-06T09:18:52+00:00Added an answer on June 6, 2026 at 9:18 am

    Wrapping the index+1 in parenthesis should get you what you want.

    $('.bbpager', obj).append('<li class="pagerButton"><a href="#"><span>'+(index+1)+'</span></a></li>');
    

    If you want, you can save that 1-based index into a variable of it’s own:

    var display_index = index + 1;
    $('.bbpager', obj).append('<li class="pagerButton"><a href="#"><span>'+ display_index +'</span></a></li>');
    

    The reason the index+1 didn’t work on it’s own is because what it does is adds from left to right and converts all of the numbers into strings.

    So what you’ll end up with is:

    '<li class="pagerButton"><a href="#"><span>{index}1</span></a></li>'
    

    Adding the parenthesis will force the index to be incremented by 1 before it starts constructing the combined string.

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

Sidebar

Related Questions

I have a bit of a noob question about Windows Setup projects here. I've
I am a noob when it comes to python. I have a python script
I hope someone can help me. I'm a bit of a noob to Java.
Bit of a noob question but: I have a custom class defined as: public
So I am creating a fading gallery and am a bit of a noob
I'm a bit of a javascript noob, but I have a general question that
I'm a bit of a noob when it comes to HTML and CSS but
I must confess I'm a bit of a noob when it comes to MSBuild
I am a bit of a Ruby noob when it comes to the more
i'm a bit of a noob with JMX and servers... I have a multi-node

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.