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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T08:18:45+00:00 2026-06-18T08:18:45+00:00

I am currently working on a simple website and I am trying to set

  • 0

I am currently working on a simple website and I am trying to set up a simple slide show that fades from one image to another. The way I have it set up currently it will load all the images from a folder into the html (dynamically) using JQuery.

I have it so that it get’s the list of image names (through php) and then just add’s the html for each image (images is just an array of the names of each image):

for(var i = 0; i < images.length; i++) {
    $('#slideshow').append('<img id="\"slide' + i + '\"" src="animations/' + images[i] + '" style=\"display: none;\"/>');
}

It then calls this method which should begin (and continue) to cycle through them. I got it working without the dynamically loaded images, but seeing as you can’t use .css or .fadeIn with dynamic content I am stuck

function countDown() {
    setTimeout(countDown, 4000);
    lastSlideNum = count;
    count++;
    if(count > images.length)
        count = 0;
    currentSlideNum = count;

    //This next part never gets called  because it can't access the dynamically created img
    $("#slide" + lastSlideNum).fadeOut('slow', function() { 
        $(this).css("display", "none");
        $("#slide" + currentSlideNum).fadeIn('slow');
    });
}

I realize it probably isn’t pretty or the easiest way of doing things, but any advice on this would help greatly. Keep in mind I’m pretty new to JQuery, so if there is a much easier way about this please let me know.

TL;DR:
Any work around for fading in and out dynamically loaded content?

  • 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-18T08:18:46+00:00Added an answer on June 18, 2026 at 8:18 am

    Try my demo here: http://jsfiddle.net/QAa7a/

    The idea is querying using $(“#slideshow img:nth-child(” + lastSlideNum + “)”):

    function countDown() {
        setTimeout(countDown, 4000);
        lastSlideNum = count + 1;
        count++;
        if(count >= images.length)
            count = 0;
        currentSlideNum = count + 1;
    
        //This next part never gets called  because it can't access the dynamically created img
        console.log(lastSlideNum + "?" + $("#slide" + lastSlideNum).length);
        $("#slideshow img:nth-child(" + lastSlideNum + ")").fadeOut('slow', function() { 
            $(this).css("display", "none");
            $("#slideshow img:nth-child(" + currentSlideNum + ")").fadeIn('slow');
        });
    }
    

    Check this link in case you don’t familiar with nth-child selector: http://api.jquery.com/nth-child-selector/

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

Sidebar

Related Questions

I'm currently working on a script that shows thumbnails from a website on a
I'm working on a relatively simple website with (currently) a single resource. I have
I am currently working on a simple Silverlight app that will allow people to
I am currently working on an ASP.NET MVC3 website. I have a simple authentication
I'm working on a simple CSS and HTML website, trying stuff out. I wanted
I am currently just working on simple and final UI changes for a website
I am currently working on my portfolio website which uses a very simple navigation.
I'm currently working on a simple interactive map for my company's website. We are
I am currently working with a client to redevelop their website. One of the
I'm working on a website with simple jquery effects, like show, hide... http://emilione.altervista.org/works.html This

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.