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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T10:09:00+00:00 2026-05-13T10:09:00+00:00

Edit : Problem wasn’t related Event Propagation, if you want to know how to

  • 0

Edit : Problem wasn’t related Event Propagation, if you want to know how to stop propagation in jQuery, then use event.stopPropagation();

When user moves his/her mouse over <span> element my jQuery code appends an <img>into this <span> element and when he moves out his mouse off <span> than the element appended is removed. It helps people to edit the field when clicking on the appended <img> element.

The reason I used append() method to add <img> into <span> is because I want to keep <img> element visible when user moves his mouse over to appended <img> element (<img> is becoming <span>‘s child element) But it didn’t happen and when user moves his mouse over it <img> is being deleted. I am thinking it is because event propagation but I couldn’t find how to activate it in jQuery as we do with addEventListener in Firefox based browsers.

Here is the code :

JQuery Code :

$(document).ready(function() {
    $('.EditEnabled').bind("mouseover", ShowEditFields);
    $(".EditEnabled").bind("mouseout", HideEditFields);
});

function ShowEditFields(event) {    
    $(event.target).append(" <img id='editImg' src='images/edit.png' style='margin-bottom:-3px'/>");
}

function HideEditFields(event) {
    $(event.target).children("#editImg").remove();
}

Simple HTML :

<span id="something" class="EditEnabled">Something Here</span>

Can you explain my how to solve it.

Thank you.

  • 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-13T10:09:00+00:00Added an answer on May 13, 2026 at 10:09 am

    You want to use the jQuery mouseenter and mouseleave events, not mousover and mouseout. The reason is that mouseout will fire when you move the mouse over the img.

    Thankfully, jQuery combines this into a hover method:

    $(document).ready(function() {
         $('.EditEnabled').hover(ShowEditFields, HideEditFields);
    });
    

    However I agree with the other answer that you should use CSS to do this vs. manipulating the DOM. I would just use the :hover pseudo selector, and then add special support for IE6.

    CSS

    span.EditEnabled img { display: none }
    span.EditEnabled:hover img,
    span.EditEnabled.hover img { display: block }
    

    Make sure you have the img in the span in your HTML to begin with, and that is all you need for most browsers and IE7+

    To support IE6 add:

    <!--[if lte IE 6]>
    <script type="text/javascript">
    $(function(){
      $(".EditEnabled").hover(
        function(){ $(this).addClass('hover') },
        function(){ $(this).removeClass('hover')}
      );
    });
    </script>
    <![endif]-->
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

EDIT: Problem wasn't related to the question. It was indeed something wrong with my
Most of you probably know the following problem: You edit an HTML, view the
I want to allow the user to edit by data by row, so only
EDIT: Problem solved. This was (yet another) situation where the problem wasn't really where
Problem Scripts on some pages that use jquery are not activating. Scenario Finding that
** EDIT ** I'm afraid I wasn't in the right direction - the problem
[EDIT: Problem solved. Please see my answer below.] In my app I call the
Ok, I'll put the code first hopefully to make it clearer. ***Edit: Problem is
Edit: This problem was down to me passing the wrong view to the Touch
[Edit: This problem applies only to 32-bit systems. If your computer, your OS and

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.