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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T15:08:59+00:00 2026-05-19T15:08:59+00:00

I have an image scroller set up, and I keep a count of the

  • 0

I have an image scroller set up, and I keep a count of the current item through a variable called current_item. Now, I want to display the alt text of the image in a list of images whose index matches the item_count.

Here’s the JQuery

var scroll_text = $('#ax_campaign_content li').index(current_item).children('img').attr('alt');
$('#ax_campaign_scroller h4').text(scroll_text);

And this is the basic html structure:

<div id="ax_campaign_content">
    <ul>
    <li><img alt="Image 1"></li>
    <li><img alt="Image 2"></li>
</ul>
</div>

<div id="ax_campaign_scroller">
    <h4>Image Text Goes Here</h4>
</div>

This is what I’m trying to do but it’s not working. Anybody see where I’m going wrong?

  • 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-19T15:09:00+00:00Added an answer on May 19, 2026 at 3:09 pm

    Your code will iterate the li elements and then iterate the images inside of that li, which will always be just one image. So what you’re doing will never get anything related to the current_item variable.

    Instead you might want to try passing current_item to .eq to first get the li element with that index, and then get the image alt attribute:

    var scroll_text = $("#ax_campaign_content li")
        .eq(current_item)
        .find("img").attr("alt");
    
    $("#ax_campaign_scroller h4")
        .text(scroll_text);
    

    Or you can do it with a one-liner (added new-lines and tabs for readability) and select the image in the same selector without using .find:

    $("#ax_campaign_scroller h4").text(
        $("#ax_campaign_content li:eq("+current_item+") img")
            .attr("alt")
    );
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have put together an image scroller using jquery, like this function rotateImages(whichHolder, start)
I have image and txt file of same size say 200 KB. Now i
So I have Image like this (source: de-viz.ru ) I want to get something
I have a jQuery tools scroller set up with controls managing two separate divs
I want to build an image scroller that works like google map. When the
I have some layout with image, I want that layout fit in screen automatically
I have a scroller maked with a plugin called simplyscroll.js in jquery. Inside It
I have an image scroller that I am trying to implement. The image scrolling
I have an image that I want to increase the size or decrease the
I have a JSplitPane. i want to add background image to the left side

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.