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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T03:27:19+00:00 2026-05-23T03:27:19+00:00

Using jquery, I am trying to get a background image to fade into a

  • 0

Using jquery, I am trying to get a background image to fade into a different one when you mouse over it, and fade out when you take your mouse off. I have tried countless solutions over the last few hours, and can’t seem to find one that applies. Below is my css

.thumbnail span {
    background: url('images/portfolio.png') no-repeat;
    width: 298px;
    height: 160px;
    position: absolute;
    top: 0;
    left: 0;
    margin-left:-2px;
    cursor: pointer;
}

.thumbnail span .rollover {
    background: url('images/portfolio_vignette.png') no-repeat;

}

and here is my JavaScript:

<script type="text/javascript">         
$(document).ready(function(){

    $(".rollover").css({'opacity':'0'});

    $('.thumbnail span').hover(
        function() {
            $(this).find('.rollover').stop().fadeTo(500, 1);
        },
        function() {
            $(this).find('.rollover').stop().fadeTo(500, 0);
        }
    )

});     
</script>

Cheers guys!

  • 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-23T03:27:19+00:00Added an answer on May 23, 2026 at 3:27 am

    Make sure to put a div wrapper around your two images and attach the hover event to that. If you don’t, your hover will continuously trigger as the image disappears/appears.

    Here, I simply fade the last element out when hovering, and in when un-hovering. Of course, you could be more specific and act on img tags only, or on specific ID’s. The generic way is more useful as you never have to write the code again for another pair of images.

    HTML:

    <div class="hoverfade">
        <img src="http://my/image1.jpg">
        <img src="http://my/image2.jpg">
    </div>
    

    jQuery:

    $(".hoverfade").hover(function() {
        $(this).children().last().fadeOut(1000);
    }, function() {
        $(this).children().last().fadeIn(500);
    })
    

    Example: http://jsfiddle.net/jtbowden/wQkWR/

    Example using divs with background images: http://jsfiddle.net/jtbowden/wQkWR/1/

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

Sidebar

Related Questions

OK, so I have these background <div> s which pan left and right using
Silly question 4 most, I guess, I'm trying to get my last li, which
My problem is I can't get this jQuery slider to start from .1 to
for this I am using colorbox jQuery plugin http://colorpowered.com/colorbox/ and a form. I am
OK, I'm trying to include some animating backgrounds using Spritely as a test on
can someone please help me make a floating menu in prototypeJS? I found documentation
I have a website built across a series of pages and scripts, and I'm
<!DOCTYPE html PUBLIC -//W3C//DTD XHTML 1.0 Transitional//EN http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd> <html xmlns=http://www.w3.org/1999/xhtml> <head> <title>Validation POC</title> <script
Integrating SimpleModal with ASP.NET I want to thank Eric for producing SimpleModal and compliment
The website to see the error (click the home, models, etc links) : http://bit.ly/9AE2RI

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.