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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T13:59:03+00:00 2026-05-31T13:59:03+00:00

Ok, so I know how to get all the li items and indices, such

  • 0

Ok, so I know how to get all the li items and indices, such as:

totalLi = $('.content li').length;
clck = $('li.content).index();

and writing something to allow clicking of any li, such as:
$(‘.content li’).click(function() {something})

and yet I can’t seem to figure out how I would:
“Click on any li in a given list, identify which it is, and based on that send a parameter to a function that would animate something else.”

The part I’m stuck on is that by using:
#(‘.content li’).click…. I don’t know how to pull the index value with a variable. I’m all over the place with “this” but alerting that only gets [object] returned so it’s to generic.

I’m guessing I should set the index to a variable but maybe not?

I’m wanting to have a dynamic routine so that whether there are 5 or 15 li’s, I can click on any of them and make something happen. The snapper is that I need to have a previous and next item. I can get those to appear easy enough, but iterating +1 or -1 seems like it would interfere with the li’s that are a, b, c, d etc. (instead of numbers, either way the list is just a navigation to go through the questions but any number could be clicked on… it’s not linear)

I’ve played with .each() and first/end etc.. I’m not getting it?

  • 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-31T13:59:05+00:00Added an answer on May 31, 2026 at 1:59 pm
    $('.content li').click(function(){ 
        var ind = $(this).index();
    })
    

    is this not working?

    $('.content li').click() binds the click event on each li element. Then when you refer to $(this) it will direct to the element which has triggered the click event and you can directly use that element. It is up to you what you want : index(), text(), html() or any other attribute.

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

Sidebar

Related Questions

Anyone know of a smooth way to get all of the selected items in
I want to get indices of all the items that are selected in given
Anybody know how to get all of these in a C# app that leads
Anybody know how to get gmail's OpenID working? All I find is this http://openid-provider.appspot.com/
I cannot seem to get this date picker working at all. I know it
This is a followup to: MySQL - Is it possible to get all sub-items
My web application needs to get the results of all the items which have
I am writing an application to compare each item on listbox1 to all items
I want to get all items from a specific list in recurring meeting workspace.
I know how to get elements with a particular attribute : $("#para [attr_all]") But

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.