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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T10:05:12+00:00 2026-06-05T10:05:12+00:00

Consider the following code (jsfiddle here ) <span class=content>foo</span><span class=closeButton>close</span> <span class=content>bar</span><span class=closeButton>close</span>​ .content

  • 0

Consider the following code (jsfiddle here)

<span class="content">foo</span><span class="closeButton">close</span>
<span class="content">bar</span><span class="closeButton">close</span>​

.content { padding: 0 4em; }
.closeButton:hover { display:inline; }
.closeButton {
    display: none;
    position: relative;
    left: -3em;
}

​$('.content').on('mouseenter', function() {
    $(this).next().css('display', 'inline');
}).on('mouseleave', function() {
    $(this).next().css('display', '');    
});
$('.closeButton').on('click', function() {
    $(this).prev().remove().end().remove();
});
​

When you mouse over the element ‘foo’ the closeButton appears using the jQuery ‘mouseenter’ event. When you click the close button ‘foo’ is removed which causes the element ‘bar’ to move under the current location of the mouse. However, the ‘mouseenter’ event does not fire for ‘bar’ until you move the mouse again.

Is there a good way to make it so that ‘bar’ receives this event immediately?

Consider that in this case you could remove multiple elements by simply clicking repeatedly. Jittering the mouse in between clicks is a bad user experience.

I am aware of several near anwsers that will not work in my case.

1) The closeButton element is not actually contained inside of the ‘foo’ element that it closes. This is required to avoid conflict with other scripts on the page and prevents using css :hover to display the button initially, which would work jsfiddle. 🙁

2) I know a little about DOMMutationEvents, their deprecation, and relative lack of support and I would like to avoid them and the various timer hacks to emulate them etc. I’m hoping that this problem is specific enough (a mouse location related event) to fire when the document has reflowed and modified the mouses target. Especially since obviously the CSS engine knows about it and handles it properly.

3) I am using jQuery to modify the page. I could monkey patch it to fire an event when I call ‘remove()’ and make sure that I “true up” all my other events. This could work but the remove could effect a large piece of the DOM and so it would be difficult to really pass any context into the handler. As a result I would have to do a lot of extra work, rather than just processing one event for the one element under the mouse. This might work now but be un-manageable later.

Thanks for any advice.

  • 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-05T10:05:14+00:00Added an answer on June 5, 2026 at 10:05 am

    There’s a nifty method called document.elementFromPoint(event.pageX, event.pageY)

    You’ll see how I’ve used it at the JSfiddle here 🙂 http://jsfiddle.net/7zEZw/1/

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

Sidebar

Related Questions

Consider the following code: struct Foo { }; struct Bar { explicit Bar(const Foo&)
Consider the following code HTML: <span class='c1'>Home<sup id='id1'>[2]</sup></span> CSS: .c1 { text-decoration:underline; } #id1
Consider the following code: $(document).ready(function() { $(body).append(<div class='outer'><span class='inner'>Click me</span></div>); $(html).click(function(event) { var targetClass
Consider the following code: @Entity @Table(name = a) public class A implements Serializable {
Consider the following code: public class MyClass { public static string MyStaticMethod() { //string
Consider the following code: #include <iostream> using namespace std; class Test { static int
Consider the following code :- public class UsingWait1{ public static void main(String... aaa){ CalculateSeries
Consider the following code in a DLL: public class ReceivingClass { private Assembly myAssembly;
Consider the following code ( http://jsfiddle.net/FW36F/1/ ): <input type=checkbox onchange=alert(this.checked)> <button onclick=document.getElementsByTagName('input')[0].checked=!document.getElementsByTagName('input')[0].checked;>toggle</button> If you
Consider the following code: class A { private $a; function f() { A::a =

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.