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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T16:23:42+00:00 2026-05-12T16:23:42+00:00

In the following markup, "image 3" would the only visible div if all .image

  • 0

In the following markup, "image 3" would the only visible div if all .image divs were positioned absolutely and with no z-index. I could "reshuffle" the deck, so to speak, by adjusting the z-index of all elements, or I could reshuffle it by manually placing the last .image div before the first, making the sequence "image 3, image 1, image 2."

<div id="images">
  <div class="image">...image 1...</div>
  <div class="image">...image 2...</div>
  <div class="image">...image 3...</div>
</div>

Suppose I would like the elements to fade, one to the other, every few seconds. I’d like to start by showing "image 3," and have it fade out only to appear after "image 1" has been displayed. I can accomplish that by giving it a lower z-index than "image 1" has, or by manually moving it before "image 1" after it’s completely faded out.

Problems with z-index…

My reservation with using the z-index route is the need to examine all of the .image divs just to find the div having the highest z-index, so I can fade it out. This would be much easier if I were manually moving them, I could merely ask for $("div.image:last"). Furthermore, I would have to re-write the z-indexes, setting "image 3" to z-index:0; after it’s been displayed, and incrementing all others to i+1.

Problems with manually moving elements…

This seems really sloppy, but as pointed out in the previous paragraph it appears to be the easiest solution. I’m not sure what effect it would have on screen-readers and other tools that require solid markup to function properly.

Which of these two methods is best for a carousel-type script, and why? Or is there a third option I’m not considering?

  • 1 1 Answer
  • 1 View
  • 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-12T16:23:42+00:00Added an answer on May 12, 2026 at 4:23 pm

    To build on what peirix and Steerpike suggested. Add display:none to your image class and set your first div to display:block. You can then find the visible div with the :visible selector and cross-fade with the next div:

    function rotate() {
        // fade out the current div
        var activeEl = $("#images div:visible");
        $(activeEl).fadeOut("slow");
    
        // fade in the next div in the loop
        if ($(activeEl).next().length) {
            $(activeEl).next().fadeIn("slow");
        } else {
            $($(activeEl).siblings()[0]).fadeIn("slow");
        }
    
        setTimeout(rotate, 1000);
    }
    
    $(document).ready(function() {
        rotate();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm having the following markup using 2 divs. the #child div has set position:absolute;
If I have the following markup <div id=previewNote class=note yellow style=left:25;top:25px;z-index:1;> <div class=body></div> <div
I have the following markup: <div class="header">Text</div> <div class="hiddenArea">sdsada</div> <div class="header">Text2</div> <div class="hiddenArea">sdsada</div> and
I have a node defined by the following HTML markup: <div id="_13:3AVAsa7qVvAprAar19ie8LRorrLEm2g" >asdf</div> I
I have the following markup, and I want to make the All radio button
I have the following markup: <div id=routes> <ul id=routesList> <li class=routes>Route 1</li> <li class=routes>Route
I have the following markup: <!-- first marker --> <div class=marker></div> <div class=tooltip> <p>My
I have the following markup. I would like to add class_A to <p class=subitem-text>
Given the following markup for a GridView column, why are my image buttons showing
I have the following markup: <div id=div-1>1st div</div> <div id=div-2>2nd div</div> <div id=div-3>3rd div</div>

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.