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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T19:10:50+00:00 2026-06-10T19:10:50+00:00

I am trying to make something, and I started reading about jQuery just yesterday,

  • 0

I am trying to make something, and I started reading about jQuery just yesterday, so it doesnt go well for me yet 🙂

However what I am trying to make is to swap the image of my logo on mouseenter/leave or hover depends on whats better…

So here is what I made and it’s definetly bad but …

    $(document).ready(function() {
    var logo = $('#logo');

    logo.on('mouseenter', function() {
        logo.css('background-image', 'url("img/logo2.png")');
    });
    logo.on('mouseleave', function() {
        logo.css('background-image', 'url("img/logo.png")');
    });
});

This works fine, it’s probably not great code either… but theres no animation like fadeIn and fadeOut… I don’t know how to make it.

Help me to make this please and thanks in advance!

  • 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-10T19:10:52+00:00Added an answer on June 10, 2026 at 7:10 pm

    In order to fade in the image you will have to load both images to begin with, one on top of the other with absolute positioning and appropriate z-index.

    Then you just have to make the image ‘on-top’ fade-out when you hover over it, to reveal the one underneath. So you never actually have to adjust the background-image of the element.

    <div id="logo-container" style="position:relative;">
        <div id="logo-above" style="position:absolute;z-index:2">
            <img src="img/logo1.png" />
        </div>
        <div style="position:absolute;z-index:1">
            <img src="img/logo2.png" />
        </div>
    </div>
    
    <script>
        $(document).ready(function() {
            var $logoContainer = $('#logo-container');
            var $logoAbove = $('#logo-above');
    
            $logoContainer.on('mouseenter', function() {
                $logoAbove.fadeOut();
            });
            $logoContainer.on('mouseleave', function() {
                $logoAbove.fadeIn();
            });
        });
    </script>
    

    p.s. its good practice to prefix variables that are ‘jqueryfied’ with $ so you know not to call jquery on them again. eg $logoContainer.

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

Sidebar

Related Questions

Well i guess im missing something here.. Any way im trying to make a
Just started learning NServiceBus and trying to understand the concept. When it talks about
Im trying to make something similar to twitpic.com's email submission feature. Their address schema
Ok I am trying to make something to ask you random multiplication questions. Now
I'm trying to make something pretty simple, but I simply suck at regular expressions.
I am trying to make something that will enable all controls if a SubString
I'm currently in a .NET4 Windows Forms Application. I'm trying to make something like
I am trying to build a Retirement Calculator as a chance to make something
Trying to make a simple program to catalogue books. Something like this, for example:
Trying to make a simple program to catalogue books. Something like this, for example:

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.