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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T03:01:01+00:00 2026-06-02T03:01:01+00:00

Hi im working with a JQuery slideshow. All my images in my html is

  • 0

Hi im working with a JQuery slideshow. All my images in my html is on top of each other, and I tried to make my code start with the last image. but it won’t work, any ideas?

the original code looks like this:

$(document).ready(function() {
    var current = $('#gallery img:first');
    //Set the fade in effect for the next image, show class has higher z-index
    current.addClass('show').css({
        opacity: 0.0
    }).animate({
        opacity: 1.0
    }, 1000);

    setInterval('gallery()', 3000);
});

function gallery() {
    //if no IMGs have the show class, grab the first image
    var current = ($('#gallery img.show') ? $('#gallery img.show') : $('#gallery img:first'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var next = ((current.next().length) ? current.next() : $('#gallery img:first'));

    //Set the fade in effect for the next image, show class has higher z-index
    next.css({
        opacity: 0.0
    }).addClass('show').animate({
        opacity: 1.0
    }, 1000);

    //Hide the current image
    current.animate({
        opacity: 0.0
    }, 1000).removeClass('show');
}​

My reverse code looks like this:

$(document).ready(function() {
    var current = $('#gallery img:last');
    //Set the fade in effect for the next image, show class has higher z-index
    current.addClass('show').css({
        opacity: 0.0
    }).animate({
        opacity: 1.0
    }, 1000);

    setInterval('gallery()', 3000);
});

function gallery() {
    //if no IMGs have the show class, grab the first image
    var current = ($('#gallery img.show') ? $('#gallery img.show') : $('#gallery img:last'));

    //Get next image, if it reached the end of the slideshow, rotate it back to the first image
    var before = ((current.before().length) ? current.before() : $('#gallery img:last'));

    //Set the fade in effect for the next image, show class has higher z-index
    before.css({
        opacity: 0.0
    }).addClass('show').animate({
        opacity: 1.0
    }, 1000);

    //Hide the current image
    current.animate({
        opacity: 0.0
    }, 1000).removeClass('show');
}​
  • 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-02T03:01:03+00:00Added an answer on June 2, 2026 at 3:01 am

    In absence of test page, I added images in ul did this:

    var before = ((current.prev().length) ? current.prev() : $('#gallery img:last'));
    

    This will select the prev image to show, if there are none then again select the last image.

    Can you try if this works for you ?

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

Sidebar

Related Questions

I'm working with a simple jQuery slideshow that creates a caption over an image
I'm working with Jquery in Drupal. I have sets of four blocks that all
I am using jQuery Tools Slideshow & Tabs for a project I am working
I've created a Jquery slideshow and it is working without problem, but this thing
I have blinking text modal dialog box and slideshow with jquery. They working just
I'm working through a jQuery image slider tutorial and I lost them at the
I am using JQuery Cycle to produce a slideshow of images. The plugin uses
I stayed up all night just trying to resolve the JQuery slideshow but I
I can't get this working. I have a flash header, and a jquery slideshow
My PHP code return JSON data to jquery autocomplete but autocomplete not working Jquery

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.