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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T14:50:30+00:00 2026-06-15T14:50:30+00:00

I have an image with an overlay DIV which shows 2 images when I

  • 0

I have an image with an overlay DIV which shows 2 images when I hover on the image, this works fine, but I want it to be dynamic and work for countless images on the page, currently it works for the first picture only, I’m not that good with javascript and jquery and would appreciate your help on this one.

Jquery Code:

$("#imageOverlay").hover(
    function() {
        $(this).children("img").fadeTo(200, 0.7).end().children("#hover").show();
    },
    function() {
        $(this).children("img").fadeTo(200, 1).end().children("#hover").hide();
});

HTML Code:

<div id="imageOverlay">
  <div id="hover">
    <a href="#"><img src="http://placehold.it/100x30&text=Full View" /></a>
    <a href="#1"><img src="http://placehold.it/100x30&text=Similar" /></a>
  </div>
  <img src="http://placehold.it/1000x1000&text=Thumbnail">
</div>

CSS Code:

#imageOverlay {
    display: inline;
    position: relative;
}
#imageOverlay #hover {
    display: none;
    position: absolute;
    margin-top: 10px;
    margin-right: 10px;
    z-index: 2;
}
#imageOverlay #hover a {
    width: 100px;
    height: 30px;
    display: block;
    margin-bottom: 5px;
}
  • 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-15T14:50:31+00:00Added an answer on June 15, 2026 at 2:50 pm

    Use a class for #imageOverlay and #hover, you can only have one instance of an ID, so when you have more than one of those IDs, the function is only finding the first one. Also, just fade the container box, not each individual image. Also, use stop() before an animation to make sure you don’t get weird behavior when people are mousing on and off your element. Then, putting the main image first ensures that the hovered images are “on top” without having to worry about z-index.

    HTML

    <div class="imageOverlay">
      <img src="http://placehold.it/1000x1000&text=Thumbnail">
      <div class="hover">
        <a href="#"><img src="http://placehold.it/100x30&text=Full View" /></a>
        <a href="#1"><img src="http://placehold.it/100x30&text=Similar" /></a>
      </div>
    </div>
    

    JS

    //fade out the images initially
    $(".imageOverlay .hover").fadeTo(0, 0)
    $(".imageOverlay").hover(
        function() {
            $(this).find(".hover").stop().fadeTo(200, 1);
        },
        function() {
            $(this).find(".hover").stop().fadeTo(200, 0);
        } //when writing clean code, be sure your closer ends at the same indent as your opener
    );
    

    CSS

    .imageOverlay {
        display: inline-block;
        position: relative;
    }
    .imageOverlay .hover {
        position: absolute;
        top: 10px;
        right: 10px;
    }
    .imageOverlay .hover a {
        width: 100px;
        height: 30px;
        display: block;
        margin-bottom: 5px;
    }
    

    And your images should show up on top when you hover!

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

Sidebar

Related Questions

I have a div which when clicks fades in an overlay image. It works
I have a tiling background image, but I want to overlay another tiling image
Ok so I have a Background background-image: url('images/body.png'); now I want to overlay a
I have a popup DIV (js triggered) which shows an image. Very simple. The
I have a small (100x80) overlay image which will be placed at x=40, y=50
I have image map that can I move, but this map will be so
so I have this jQuery script below that works. But since I'm just learning
basically I have 4 images with divs set up like this: <div id=selector> <div
I have a div which when hovered scales up in size - This all
I have image Array with two images out of that first image its showing

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.