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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 20, 20262026-05-20T12:27:11+00:00 2026-05-20T12:27:11+00:00

I have a div which currently has a static background image. I need to

  • 0

I have a div which currently has a static background image.

I need to create a slideshow of background images for this div.

I am able to achieve this by just setting a timeout and then changing the background image in the CSS but this is not very elegant.

I would ideally like to fade the background images out and in, but the div contains other page elements so I can not alter the opacity in any way.

Does anyone know of a good way to do this using jquery??

Here’s some code which fades out/in but fades out the contents of the div too.

$("#slideshow").fadeOut(5000, function(){
    $("#slideshow").css('background-image','url(myImage.jpg)');
    $("#slideshow").fadeIn(5000);
});
  • 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-20T12:27:12+00:00Added an answer on May 20, 2026 at 12:27 pm

    HTML:

    <div class="slideshow"></div>
    

    CSS:

    .slideshow
    {
        position: relative;
        width: 350px;
        height: 150px;
    }
    .slideshow img
    {
        position: absolute;
        width: 350px;
        height: 150px;
        z-index:-1;
    }
    

    jQuery

    var images=new Array('http://placehold.it/250x150','http://placehold.it/250x150/123456','http://placehold.it/250x150/dbca98');
    var nextimage=0;
    
    doSlideshow();
    
    function doSlideshow()
    {
        if($('.slideshowimage').length!=0)
        {
            $('.slideshowimage').fadeOut(500,function(){slideshowFadeIn();$(this).remove()});
        }
        else
        {
            slideshowFadeIn();
        }
    }
    function slideshowFadeIn()
    {
        $('.slideshow').prepend($('<img class="slideshowimage" src="'+images[nextimage++]+'" style="display:none">').fadeIn(500,function(){setTimeout(doSlideshow,1000);}));
        if(nextimage>=images.length)
            nextimage=0;
    }
    

    jsfiddle Demo

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

Sidebar

Related Questions

I have DIV element which only has a few lines in and a background
I need help in Stylesheet. I have a div which has: Header text with
I have a page which has a slideshow at the top, and images inserted
I have div which has three buttons as, <div id=buttons> <input id=preview class=ButtonStyle type=submit
I have a div which I have attached an onclick event to. in this
Currently I have this JQuery script var img = $(this); img.wrap('<div class=photo></div>'); img.parent().append(<p> +
I have a DIV to which I want to apply a style currently prescribed
I currently have something similar to this, it loads a div on the target
I need some jQuery ajax help. I currently have a main content div that
I currently have an HTML page that has a grey BODY background. Now I

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.