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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T10:45:43+00:00 2026-05-23T10:45:43+00:00

I have a navbar thing going on here , at the bottom. Basically when

  • 0

I have a navbar thing going on here, at the bottom.

Basically when the user hovers over an image it should change the filename from xyz.png to xyz-hover.png, showing a new image. With the cool fade.

Except, every image hovered over changes to the same image.

Anyone know a way around this?

    <script type="text/javascript">

$(document).ready(function() {
      // Change the image of hoverable images
      var openPng = $(".fadeim").attr("src");
      var closedPng = openPng.replace(".png", "-hover.png");


$(".fadeim").hover(function() { 
            $(this).stop(true, true).fadeOut(700, function() {
                  $(this).attr("src", closedPng).fadeIn(700);
            });


      }, function() {

            $(this).stop(true, true).fadeOut(700, function() {
                  $(this).attr("src", openPng).fadeIn(700);         
            });
      });
});


</script>
  • 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-23T10:45:44+00:00Added an answer on May 23, 2026 at 10:45 am

    the variable openpng and closepng should be defined in for each loop.

    $(document).ready(function() {
          // Change the image of hoverable images
    
    $(".fadeim").each(function(){
    var openPng = $(this).attr("src");
    var closedPng = openPng.replace(".png", "-hover.png");
    $(this).hover(function() { 
                $(this).stop(true, true).fadeOut(700, function() {
                      $(this).attr("src", closedPng).fadeIn(700);
                });
    
    
          }, function() {
    
                $(this).stop(true, true).fadeOut(700, function() {
                      $(this).attr("src", openPng).fadeIn(700);         
                });
          });
    })
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Alright, so here is the situation... Say I have a navbar for a site,
so i have a simple navbar with a dropdown menu for when a user
I am trying to make a php navbar sort of thing. I have the
I have a navbar that drops down. The parent text is black, when you
I have a nav bar with children unordered lists nested under the main navbar
If I have a chunk of code like this: .hover( function () { hoverState($(#navbar
I'm making a ul-based horizontal navbar, but I want to have two levels heading
I have a set of UIViews arranged in layers one over another. I've added
I have view which contains a scrollView. When the view shows up the image
I have a small MVC site that uses the Html.ActionLink helper for a navbar.

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.