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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:10:16+00:00 2026-05-29T05:10:16+00:00

a div has few image and the code below is showing one image at

  • 0

a div has few image and the code below is showing one image at a time. it is just like slide show. i read the code but just do not understand how it is working. the code is tested and it is working. only one problem found that sometime animation run so fast. i just do not understand what is wrong in the code as a reason sometime images changes very fast in slide show.

here is html and jquery code

<div class="headerCarouselwrapper">
            <img src="http://www.bba-reman.com/NewSiteImages/new-bba-header-image1.jpg" />
            <img src="http://www.bba-reman.com/NewSiteImages/new-bba-header-image2.jpg" />
            <img src="http://www.bba-reman.com/NewSiteImages/new-bba-header-image3.jpg" />
            <img src="http://www.bba-reman.com/NewSiteImages/new-bba-header-image4.jpg" />
</div>

$(document).ready(function () { 
$('.headerCarouselwrapper img:gt(0)').hide();
    setInterval(function () {
        $('.headerCarouselwrapper :first-child').fadeOut()
        .next('img').fadeIn()
        .end().appendTo('.headerCarouselwrapper');
    }, 5000);
});

two things i need to know

1)how this code works. if possible then tell me how each like works

2) why sometime slide show animation run very fast.

thanks

  • 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-29T05:10:17+00:00Added an answer on May 29, 2026 at 5:10 am
    1. The code is wrapped within a “ready” handler. The anonymous function bind to the “ready” event is execute once the DOM is loaded (the “load” event fires when all assets in a page are loaded – html, images, js, css…)

       $(document).ready(function () { 
           // executes when the DOM is ready
       });
      

      jQuery ready event

    2. Hide all images except the first one:

      $('.headerCarouselwrapper img:gt(0)').hide();
      

      The pseudo selector allows matching elements with an index greater-then then one specified. .headerCarouselwrapper img finds all images in container and :gt(0) filters to have all except the first one.

      :gt() selector

    3. Every 5 seconds, execute a function:

      setInterval(function () {
          // executes every 5000 milliseconds
      }, 5000);
      

      setInterval()

    4. In the anonymous function executed every 5sec, takahe the first child of the container with class .headerCarouselwrapper (basically the visible image) and fade it out, get the next image with .next() and fade it in. Append the image that was faded out to the container to it cycles:

      // get first child in ".headerCarouselwrapper" which is the currently
      // visible image and fade it out
      $('.headerCarouselwrapper :first-child').fadeOut()
      // get the next <IMG> and fade it in
      .next('img').fadeIn()
      // get back the image that was faded out
      // and append it (move it) at the end of the container
      // so the slideshow cycle
      .end().appendTo('.headerCarouselwrapper');
      

      .end()
      .append()


    About the problem of the fast animation

    As you told in the comment, you are using jquery 1.6.2.

    jQuery 1.6 introduced support for the API requestAnimationFrame (supported in FF and Chrome, but not IE I think). It has revealed to be problematic:

    No more animation “worm holes”: We had high hopes for the browser’s
    requestAnimationFrame API when we added support into version 1.6.
    However, one of the highest-volume complaints we’ve received since
    then relates to the way requestAnimationFrame acts when a tab is not
    visible. All the animations initiated when the tab is invisible
    “stack” and are not executed until the tab is brought back into focus.
    Then they all animate at warp speed!
    We’ve removed support for this
    API (which has no impact on the way you call jQuery’s animation
    features) and plan to incorporate it into a future version of jQuery.

    You should upgrade your jquery version to at least 1.6.3.

    Source

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

Sidebar

Related Questions

I'd like to show a div that has a background-color with the height and
I've read a few solutions on here, but my problem differs enough where those
I am really struggling with this one. Below is an image of a layout
I believe that this question has been asked in a few different forms, but
I'm building a page that has a few divs of content that will slide
I know I'm just being OCD about a few milliseconds worth of performance time,
I have a div and an iframe on the page the div has z-index:
I have a div with float:right (no position property declared). This div has some
i have a click event for $('#blah div'). div has text inside of it
i'm having the following markup using 2 divs. the #child div has set position:absolute;

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.