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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:13:09+00:00 2026-06-09T10:13:09+00:00

I am trying get this background to fade in on click. I found one

  • 0

I am trying get this background to fade in on click. I found one tutorial that was helpful, and I ended up created the code so it has two images, and they fade in and out on click to bring up the picture.
Here’s the work: http://www.mccraymusic.com/bgchangetest.html

Only a couple of issues though:

  1. How do I make this work without the images getting selected at random? I’d like it to just switch from the plain black image to the image with the drum set. (And cross-fade to if possible, but not necessary)

  2. How do I center the image on the page, so the image of the drums are centered?

  • 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-09T10:13:12+00:00Added an answer on June 9, 2026 at 10:13 am

    I’m guessing this is what you’re after:

    $(function() {
        var images = ["black.jpg","bg.jpg"];
        $('<img>').attr({'src':'http://www.mccraymusic.com/assets/images/'+images[0],'id':'bg','alt':''}).appendTo('#bg-wrapper').parent().fadeIn(0);
    
        $('.entersite').click(function(e) {
            e.preventDefault();
            var image = images[1];
            $('#bg').parent().fadeOut(200, function() {
                $('#bg').attr('src', 'http://www.mccraymusic.com/assets/images/'+image); 
                  $(this).fadeIn(1000);
            });
            $(this).fadeOut(1000, function() {
                $(this).remove();
            });
        });
    });​
    

    DEMONSTRATION

    Also added :

    display: block;
    margin-left: auto;
    margin-right: auto;
    

    to your #bg element to center the image.

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

Sidebar

Related Questions

I am trying to get this piece of code working in C#, what I
Hi I'm trying to get this $( <div class=\images\ style=\background:url(' + item.link + ')no-repeat
I'm trying to get some simple piece of code I found on a website
I have spent the last 3 hours trying to get this code working. I
Using jquery, I am trying to get a background image to fade into a
I'm trying to get some better logic behind this before I start writing code.
I am trying to get this transparent background to work. When the nav drops
I get this problem in IE7 when running a piece of code that uses
Trying to get this code to work but the error I am getting in
I've been trying to get this snippet of python code to work, but to

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.