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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T20:57:56+00:00 2026-06-10T20:57:56+00:00

I am trying to make a prensentation using jquery but the next button is

  • 0

I am trying to make a prensentation using jquery but the next button is working fine but the back button is not working as i expected please help me to fix this. thanks in advance.

i have tried here

here is my html code:

<div id="slider">
<div id="next">Next</div>
<div id="prev">Back</div>
<div class="slide s1">I'm slide 1</div>
<div class="slide s2">I'm slide 2</div>
<div class="slide s3">I'm slide 3</div>

​

here is my script:

var c=0;
var b=3;
$('.slide:gt(0)').hide();
$('#next').click(function(){
c++;
$('.slide').eq(c).css({zIndex : c}).show('slow');
});
$('#prev').click(function(){
b--;
$('.slide').eq(c).css({zIndex : b}).show('slow');
});​
  • 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-10T20:57:58+00:00Added an answer on June 10, 2026 at 8:57 pm

    You didn’t keep track of your slides properly. You don’t need two indexes, just show a new slide on top of the others when the user clicks next, and hide the top slide when the user clicks back.

    Like this:

    var c=0;
    $('.slide:gt(0)').hide();
    $('#next').click(function(){
        if(c < $('.slide').size()-1) c++;
        $('.slide').eq(c).css({zIndex : c}).show('slow');
    });
    $('#prev').click(function(){
        if(c>0){
            $('.slide').eq(c).css({zIndex : c}).hide('slow');
            c--;
        }
    });​
    

    See this fiddle (UPDATED TO WORK FOR UNDETERMINED NR OF SLIDES)

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

Sidebar

Related Questions

Trying to make a small countdown timer in my app but it's not working.
Trying to make this jQuery filter that uses .find case-insensitive. For example, when the
I'm trying to make a mouse over for a stack panel in WPF using
The XAML below is basically trying to make a list of Button s (rendered
I'm trying to make a presentation using the Beamer class. I want to show
I'm trying to make a presentation on ggplot2 graphics using beamer + sweave. Some
I'm trying to make a color picker in Silverlight similar to this one but
I'm new to vs10 and I'm trying to make a customized schedule/calender using WPF.
I'm trying to make a custom button, my only problem is that the background
I'm trying to make some simple XML with Java and org.w3c.dom, but I got

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.