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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T20:19:28+00:00 2026-05-22T20:19:28+00:00

I have a jQuery slideshow code that works fine with the following HTML structure:

  • 0

I have a jQuery slideshow code that works fine with the following HTML structure:

<div id="slideshow">
    <div id="slideshowImages">
        <img src="image1.jpg" alt="" />
        <img src="image2.jpg" alt="" />
    </div>

    <div id="slideshowNav">
        <span id="slideshowLeft"><a href="#"><img src="images/slideshowLeft.png" alt="&gt;" /></a></span>
        <span id="slideshowRight"><a href="#"><img src="images/slideshowRight.png" alt="&lt;" /></a></span>
    </div><!-- /#slideshowNav -->
</div><!-- /#slideshow -->

Though now I wanted to modify it so that it’ll work with the same structure, but instead of just plain images, the images are now links. That is, the “meat” of the slideshow markup is now:

<a href="#"><img src="image1.jpg" alt="" /></a>
<a href="#"><img src="image2.jpg" alt="" /></a>

The jQuery code that makes the slideshow work is a bit lengthy, so I figured I’ll just post the necessary stuff. It works on this principle:

jQuery('#slideshowImages img:first').addClass('active');
jQuery('#slideshowImages img:last').addClass('lastImg');

var $active = jQuery('#slideshowImages img.active');

var $previous = $active.prev().length ? $active.prev(): jQuery('#slideshowImages img.lastImg');

    $active.animate({opacity:0.0}, 300, function() {
        //when done animating out, animate next in
        $previous.css({opacity:0.0})
            .animate({opacity: 1.0}, 400, function() {
            $active.removeClass('active');
            $previous.addClass('active');
    });
});

If I console.log() $active and $previous, I keep getting the same thing. Is there any way I can make the $previous variable actually be the previous image as before? I think .prev() now is making it go to the anchor link instead of the previous image, though I may be wrong.

To see a live version of this code, it can be viewed at http://engineercreativity.com/samples/daf. The site is not in English, though I don’t think that should affect anything.

Thanks for your help!
Amit

  • 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-22T20:19:29+00:00Added an answer on May 22, 2026 at 8:19 pm

    try to use as a relative selector <a> tag: it may help

    jQuery('#slideshowImages a:first').addClass('active');
    

    jQuery(‘#slideshowImages
    a:last’).addClass(‘lastImg’);

    var $active = jQuery(‘#slideshowImages
    a.active’);

    var $previous = $active.prev().length
    ? $active.prev():
    jQuery(‘#slideshowImages a.lastImg’);

    $active.animate({opacity:0.0}, 300, function() {
        //when done animating out, animate next in
        $previous.css({opacity:0.0})
            .animate({opacity: 1.0}, 400, function() {
            $active.removeClass('active');
            $previous.addClass('active');
    }); });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Say I have jquery code like this: html += '<div class=index>' + item.index +
I have some jQuery/JavaScript code that I want to run only when there is
I have some jQuery code. I have called an Ajax function file, file.php, that
I have this jQuery code that queries an API on a keyup event (via
I have written jQuery code, in files Main.html and ajax.php . The ajax.php file
Well, I have this jQuery image slideshow that uses the attribute control inside an
I have a jQuery datepicker that I want to restrict non work days -
I'm building a simple slideshow using jQuery. I have the basics down, but as
I am trying to implement a slideshow using jQuery I have a button called
Right now, we have a slideshow of images that uses javascript. However, when the

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.