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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T17:47:16+00:00 2026-06-01T17:47:16+00:00

I am using .index() to get the position of the element. So by default

  • 0

I am using .index() to get the position of the element. So by default it returns 0 for first one. Is there is a way to set default to 1 so the returned index would be 1,2,3… instead of 0,1,2…?

<div class="tabs">
    <a href="">1</a>
    <a href="">2</a>
    <a href="">3</a>
</div>

and the jQuery:

$(function(){
    $('.tabs a').click(function(e){
        var index = $('.tabs a').index(this);
        console.log(index);
        e.preventDefault();
    });
});
  • 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-01T17:47:17+00:00Added an answer on June 1, 2026 at 5:47 pm

    You can’t change the default, but you could add it manually

    var index = $('.tabs a').index(this) + 1;
    

    If that’s not good enough, you could create a plugin that would return the value you want.

    (function($){
        $.fn.myIndex = function(x) {
            return $(this).index(x) + 1;
        };
    })(jQuery);
    

    So you can then use .myIndex and get jQuery’s index with 1 added to it.

    Live example

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

Sidebar

Related Questions

Using .index() we can get the position or index of an element. Now i
How to get checked RadioButton Index using jQuery? I need to read it and
How to get Selected row index in DBGrid ? so Im using ADOQuery ->
What's the best way for selecting a table row by index using jQuery? Thanks
I am trying to find a clean way of referencing an array's index using
How do I get the value of the index position in the array, whose
I am using the jQuery Tools Tooltip (http://flowplayer.org/tools/tooltip/index.html), and I'm trying to get the
I'm trying to get consistent centering cross browser when I set the position property
Using a SQLite SELECT statement, I'd like to be able to get the position
I'm starting to get things set up using flatiron as the toolset for 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.