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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T23:11:00+00:00 2026-06-03T23:11:00+00:00

I have a group of images I’m using as a slide show. The javascript

  • 0

I have a group of images I’m using as a slide show. The javascript I’m using looks at which image has the .active class on it to know which image is being displayed. The trouble is, jQuery’s .index() function isn’t working as I would expect it to. So for:

<div id="Phase1">    
    <img src="_images/Phase1-Slide1.jpg" alt="1" class="active">
    <img src="_images/Phase1-Slide2.jpg" alt="2">
    <img src="_images/Phase1-Slide3.jpg" alt="3">
    <img src="_images/Phase1-Slide4.jpg" alt="4">
    <img src="_images/Phase1-Slide5.jpg" alt="5">
    <img src="_images/Phase1-Slide6.jpg" alt="6">
</div>

Relevant javascript:

// works fine
var i = $(".active").index("img");
alert(i);  

// does not work
var i = $(".active").index("#Phase1 img");
alert(i);  

I need to be able to specify the parent div because I’m working with 2 slideshows, and they will each have a different active image, and different total number of images.

I’ve tried all different ways but can’t get it to work with the parent div. Here’s the fiddle: http://jsfiddle.net/mBVpc/

  • 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-03T23:11:02+00:00Added an answer on June 3, 2026 at 11:11 pm

    Try this:

    $('#Phase1 img.active').index();
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a group of images which I would like to display in a
I'm using GridFS to store images. Each image has a group_id in it's meta
I have the following code, it calculates the width of a group of images
I have a group of three radio buttons. Depending on which radio button is
I have a group of 13 properties in a class. I created a struct
I have a group of categories where the slug of each has a prefix
I have a query which shows all images from a user. (In this case
I have a query which shows all images from a user. (In this case
I have a group of H.264 images (I-frames only) that I want to encode
I have several images, and I need to be able to group and select

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.