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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T22:34:21+00:00 2026-05-19T22:34:21+00:00

Using .index() we can get the position or index of an element. Now i

  • 0

Using .index() we can get the position or index of an element. Now i want to know that
can we get the element’s id using its index ?

An Example,

<ul id="unOrderedList">
<li id="gears"><a class="links" href="#">Click here!</a></li>
<li id="tyres"><a class="links" href="#">Click here!</a></li>
<li id="rear"><a class="links" href="#">Click here!</a></li>
<li id="mirror"><a class="links" href="#">Click here!</a></li>
<li id="charger"><a class="links" href="#">Click here!</a></li>
<li id="port"><a class="links" href="#">Click here!</a></li>
<li id="list"><a class="links" href="#">Click here!</a></li>
</ul>

For the above mark up, if i want to know 4th <li> id means, how shall it do it with jquery?

Thanks in Advance!

  • 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-19T22:34:22+00:00Added an answer on May 19, 2026 at 10:34 pm

    If you have the index ahead of time, just use the :eq selector, like so:

    $("#unOrderedList li[id^=list]:eq(3)").attr("id")
    

    or use the .eq filter method:

    $("#unOrderedList li").eq(3).attr("id")
    

    EDIT: I’m guessing that this is what you’re after:

    $("#unOrderedList li a.links").click(function() {
        alert($(this).parent().attr("id"));
    });
    

    Try it here.

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

Sidebar

Related Questions

How can I loop through directories with specified nesting index using C#? Little example:
I am using query index() method to get the index of an element relative
I have a single XML file that I want to index using Lucene.NET. The
Using Oracle, how can I find index names and creation dates from systables/information_schema? How
How to get checked RadioButton Index using jQuery? I need to read it and
I can't get jQuery working at all with IE7. I'm using the jQuery Cycle
I am using an index.jade to show: !=partial('_blogPost.jade', blogPost) and in _blogPost.jade : div.row-fluid
I've built a search index using the PHP Zend Framework Search (based on Lucene).
I am trying to put together an index using terms, which I specify as
What's the best way for selecting a table row by index using jQuery? Thanks

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.