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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:08:15+00:00 2026-06-15T03:08:15+00:00

I’m looking to create a bespoke slider and need some help. In theory, it

  • 0

I’m looking to create a bespoke slider and need some help. In theory, it should be relatively simple. I’m making it look incredibly difficult.

I’ve created two buttons – a #prev-btn and a #next-btn and I want them to toggle between three ‘slides’ of DOM elements. At the moment you’ll be screaming at me to use a slideshow plugin. However, the issue is that these aren’t actually slides, but are in fact DOM elements scattered around the page that I want to turn on/off by fading them in/out.

I have given each of the DOM elements I want to show classes named ‘.first’, ‘.second’ and ‘.third’ to correspond with which ‘phase’ I want them to show in.

<div id="1" class="first"></div>
<div id="2" class="second"></div>
<div id="3" class="third"></div>

.second, .third {display: none;}

Obviously, when .first objects are displayed, #prev-btn should fadeOut the .first objects and fadeIn .third classes. Also when .first objects are visible, #next-btn should fade out .first objects and display .second classes. You get the idea. This is the bit I’m struggling on.

I’ve had a fiddle around with addClass and removeClass, but I can’t seem to come up with an elegant solution without repeating a click function for every class added to #prev-btn AND #next-btn. Which we all know would be ridiculous (sample of laboriously ridiculous code below).

$j("#prev-btn.first").click(function(){
    $j("#prev-btn").addClass('third').removeClass('first');
    $j("#next-btn").addClass('third').removeClass('first');
    $j(".first").fadeOut(500, function(){
        $j(".third").fadeIn(500);
    });
});
$j("#next-btn.first").click(function(){
    $j("#prev-btn").addClass('second').removeClass('first');
    $j("#next-btn").addClass('second').removeClass('first');
    $j(".first").fadeOut(500, function(){
        $j(".second").fadeIn(500);
    });
});

So, as you can tell from that nonsense, I’m not yet the brightest spark at jQuery and can’t do the clever stuff just yet, so cheers in advance for the help! If anyone can implement an autoslide timer into this too, then wow – just wow. But it’s not 100% necessary. Cheers!

  • 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-15T03:08:16+00:00Added an answer on June 15, 2026 at 3:08 am
    elem = ['first', 'second', 'third'];
    var current = 0, previous = 0, n_elem = elem.length;
    function change() {
        $j("." + elem[previous]).fadeOut(500, function(){
            $j("."+elem[current]).fadeIn(500);
        });
    }
    $j("#prev-btn").click(function(){
        previous = current;
        --current;
        if(current === -1) {
            current = n_elem - 1;
        }
        change();
    });
    $j("#next-btn").click(function(){
        previous = current;
        ++current;
        if(current == n_elem) {
            current = 0;
        }
        change();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have just tried to save a simple *.rtf file with some websites and
I'm making a simple page using Google Maps API 3. My first. One marker
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
In my XML file chapters tag has more chapter tag.i need to display chapters
I am doing a simple coin flipping experiment for class that involves flipping a
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.

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.