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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:35:34+00:00 2026-06-07T11:35:34+00:00

I am using this syntax option for jquery hover. Here is my code: $(‘mySelector’)

  • 0

I am using this syntax option for jquery hover.

Here is my code:

$('mySelector')
    .hover(
        function(){
            $(this).html('<img src="images/myImage2.png" height="23" width="24" />');
        },
        function(){
            $(this).html('<img src="images/myImage1.png" height="23" width="24" />');
        }
    );

The original text for the element referenced by mySelector is the mouseleave option – $(this).html('<img src="images/myImage1.png" height="23" width="24" />');

The first handler, for mouseenter/mouseover, is working correctly. But the second handler, for mouseleave/mouseout (which should restore the original image), never executes. When I trace it in firebug, the mouseover event is triggered, but the second “function()” is not reached.

Edit:

For clarity, my html code is something like this:

<div id="results">
   <span class="imageClass"><img src="images/myImage1.png" height="23" width="24" /</span>
</div>

And then my selector is "#results .imageClass"

  • 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-07T11:35:36+00:00Added an answer on June 7, 2026 at 11:35 am

    The reason for this problem could be that the element which triggered the mouseenter event (i.e. the <img> node) is removed from the DOM before it can trigger the mouseleave event. The event is caught and handled by mySelector‘s event handler, but the <img> is the actual source of the event. It would therefore make sense that the mouseleave event is not triggered by the new <img>, because the mouse never entered it in the first place.

    To clarify: the DOM node to which the event handler is bound (mySelector) is not the same as the node which first triggers the event (the <img>). Because the <img> has no handler of its own for this event, the event will bubble up through the DOM tree until it encounters a node which does (in this case, mySelector).

    It turns out that adeneo’s solution does work, despite the fact that his/her answer was inaccurate. Here is a working example: jsbin.com/ikolog.

    Helpful resources:

    • DOM Events (MDN)
    • Event Propagation Example (MDN)
    • How to Stop Event Propagation (MDN)
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i am using this code <a onclick=javascript:var t=setInterval(GetUpdates(5,ajaxResult),300);>GetUpdates</a> but getting the syntax error
<script type=text/javascript> var $j = jQuery.noConflict(); $j(document).ready( function(){ //is this right syntax for jquery
What's the point using this syntax div.card > div.name What's the difference between this
What's the difference between reading a value from an SqlDataReader using this syntax: Dim
I've embedded a SWF into a class using this syntax above my class definition:
It is possible to do this using dot syntax without using eval (evil)? (I
I'm aware of using syntax like this: (something) ? TRUE : FALSE But what
How to make this (PostgreSQL) using Rails syntax?: SELECT fld1, fld2 FROM ( SELECT
I'm using sqlite3 and this would be pretty easy if it supported TOP syntax
Using the C# object initializer syntax I can instantiate an anonymous object like this:

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.