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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:37:43+00:00 2026-06-17T22:37:43+00:00

When the user hovers over the image with id=dot0001 a table with id= info0001

  • 0

When the user hovers over the image with "id=dot0001" a table with id= "info0001" that contains a checkbox with id="checkbox0001" becomes visible. When the user checks the box the image with id="dot0001" is replaced with an image that has the same id. That part works fine, the user can check and uncheck as much as he wants, the images are replaced correctly. The problem: the table does not come up when the user hovers over the image again after leaving it.

Here I define the function:

function makevisible(a){ 
    $("#tablespace").after(
        '<table  border="4" id="info'+a+'"class="info'+a+'">'+
        '<tr><td>Add to favorits</td><td><input name="" type="checkbox" id="checkboxinfo'+a+'" value=""></td></tr>')

        $("#info"+a).css("visibility", "hidden")

        $('#checkboxinfo'+a).change(function() {

        if($('#checkboxinfo'+a).is(':checked')){
    $('#dot'+a).replaceWith('<img src="_index/_dots/dotfavorit.gif" id="dot'+a+'" class="dot'+a+'">')
        }
else{
    $('#dot'+a).replaceWith('<img src="_index/_dots/dotnormal.gif" id="dot'+a+'" class="dot'+a+'">')  
    }   
    })

};

Here I use the function:

$(document).ready(function() {
    $("#dot0002").hover(makevisible("0002"))
    })

This makes the table visible and hidden after it has been added to the html:

    $(document).ready(function() {

$("#dot0002").hover(
  function(){
    $("#info0002").css({"visibility":"visible"});
  },
  function(){
    $("#info0002").css({"visibility":"hidden"});
  }
);

$("#info0002").hover(
  function(){
    $(this).css({"visibility":"visible"});
  },
  function(){
    $(this).css({"visibility":"hidden"});
  }
);
});

Here is a fiddle: http://jsfiddle.net/QzX9C/

I assume the problem is that jQuery does not find the image associated with the id after it has been replaced.

Any help appreciated!

  • 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-17T22:37:44+00:00Added an answer on June 17, 2026 at 10:37 pm

    Because you dynamically add elements to the DOM the Hover function dose not get attached to your new elements:

    this:

    $("#dot0002").hover(
    function () {
        $("#info0002").css({"visibility": "visible"});
    },
    function () {
        $("#info0002").css({"visibility": "hidden"});
    });
    

    will not be attached to the image because it is injected dynamically to the DOM by this line of code:

    $('#dot'+a).replaceWith('<img src="_index/_dots/dotfavorit.gif" id="dot'+a+'" class="dot'+a+'">')
    

    unless you reattach it by adding a hover trigger to the .change() function

    $('#checkboxinfo' + a).change(function () {
        if ($('#checkboxinfo' + a).is(':checked')) {
            $('#dot' + a).replaceWith('<img src="_index/_dots/dotfavorit.gif" id="dot' + a + '" class="dot' + a + '">')
        } 
        else {
            $('#dot' + a).replaceWith('<img src="_index/_dots/dotnormal.gif" id="dot' + a + '" class="dot' + a + '">')
        }
    
        //Add this code at the end to reattach the hover event on the newlly injected image
        $('#dot' + a).hover(
        function () {
            $("#info" + a).css({"visibility": "visible"});
        },
        function () {
            $("#info" + a).css({"visibility": "hidden"});
        });
    })
    

    Here is your fiddle updated: Link…

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

Sidebar

Related Questions

I have an image on my page and when the user hovers over it
I have a nav that has subnavs. When the user hovers over the li's
I have a submit button that changes when the user hovers his mouse over
what i'm trying to do: When a user hovers over an image, a little
I use Styles to define what happens when a user hovers over an image
I have a simple bit of code, when the user hovers over an image
I need to show an additional image once the user hovers over button. How
I'm working on a program where the user hovers over an image and a
I have an image link. When the user hovers over the image, an info
I have set up my page so that when the user hovers over an

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.