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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T11:53:43+00:00 2026-05-25T11:53:43+00:00

This is less of a specific problem or error but more of a implementation

  • 0

This is less of a specific problem or error but more of a implementation question.

First of I’d like to say that I’ve been through a lot of fading image tutorials and I have a basic understanding of the different kinds. I hope this doesn’t get thrown out along with the other hundreds of questions about fading images.

This is basically what I would like: An image fading into another image on hover using javascript and preferably jQuery. I would create two images—one named image.jpg and another named image_o.jpg. They would reside in the same folder.

Here’s what the html markup would look like:

<img class="imghover" src="image.jpg" />

The javascript would require me to have the imghover class on all the images that I want to hover. The script would detect the second image named imghover_o.jpg and use it for the second image in the hover fade transition.

There would be no required CSS or background-image for the transition.

I will have several of these images in a grid and they will all need to have the fade transition. So, you can see that I do not want to make a new CSS class for every image, or have extra script and html markup that will get cumbersome.

All of the above is achieved with this Daniel Nolan script minus the fade transition. The script just swaps the image with no fade, but it is set up perfectly with minimal code.

So you could say that I just want add a fade transition to the Daniel Nolan rollover script. Is is possible to remake his script using jQuery?

Is this possible (with jQuery)?

The site I will use it on

  • 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-25T11:53:43+00:00Added an answer on May 25, 2026 at 11:53 am

    You can get the src attribute of an image and use .replace() to replace the url on hover!

    WORKING DEMO

    $('.fadein').each(function() {
    
        var std = $(this).attr("src");
        var hover = std.replace(".jpg", "_o.jpg"); 
        $(this).clone().insertAfter(this).attr('src', hover).removeClass('fadein').siblings().css({
            position:'absolute'
        });
        $(this).mouseenter(function() {
            $(this).stop().fadeTo(600, 0);
        }).mouseleave(function() {
            $(this).stop().fadeTo(600, 1);
        });
    });
    

    Or like:

    THIS

    $('.fadein').each(function() {  
        var std = $(this).attr("src");
        var hover = std.replace(".jpg", "_o.jpg");
        $(this).wrap('<div />').clone().insertAfter(this).attr('src', hover).removeClass('fadein').siblings().css({
            position:'absolute'
        });
        $(this).mouseenter(function() {
            $(this).stop().fadeTo(600, 0);
        }).mouseleave(function() {
            $(this).stop().fadeTo(600, 1);
        });
    });
    

    What the script does:

    • var std = $(this).attr("src"); grab the SRC attribute
    • replace the imageRed.jpg with imageRed_o.jpg : var hover = std.replace(".jpg", "_o.jpg");
    • Than we had to wrap the first image into an element $(this).wrap('<div />')
    • so that now we can clone that image and give it a different src and place it UNDERNEATH the first one .clone().insertAfter(this).attr('src', hover)
    • and we have to remove from the second image the class ‘.fadein’ (only the first image will have that class!) .removeClass('fadein')
    • after we cloned that image we set the image one OVER the second by assigning it a css position absolute: .siblings().css({position:'absolute'});
    • Than on mouse enter/leave we can just play with the visibility of the first image.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I aware that this will be a less programming question, but still... How can
I use C# code more-or-less like this to serialize an object to XML: XmlSerializer
This is a fundamental question, but an important one none the less... When starting
I've thought of some less than elegant ways to solve this, but I know
Ok, this is less of a question than it is just for my information
There is another recent Project Euler question but I think this is a bit
I realize this is fairly abstract, but I'd like to do something not unlike
Hopefully this is less complex than I think. I have one table of companies,
Is there a less brute-force way to do this? #!/bin/ksh THIS_SCRIPT=$(/usr/bin/readlink -f $(echo $0
Wikipedia's Wavelet article contains this text: The discrete wavelet transform is also less computationally

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.