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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T21:49:45+00:00 2026-05-25T21:49:45+00:00

In the application I’m working on, I use span tags in long paragraphs to

  • 0

In the application I’m working on, I use span tags in long paragraphs to provide both:

  • A clickable link, handled with Javascript, and

  • On mouseover, an “edit this” button displayed to the side of the link (with different functionality from the click).

Placing and showing the “edit this” button on mouseover is relatively easy. What I’m trying to figure out is, how can I properly hide the button on mouseleave?

See my working example: http://jsfiddle.net/nrabinowitz/6uKk8/4/

The problem:

  • I can’t just use the mouseleave event on the span, because that would hide the button before it can be clicked.

  • I can’t use a transparent div sized to include both the span and the button, because if the div is above the span, it blocks the click event, and if I use the z-index to place the div below the paragraph, it doesn’t seem to receive the mouseleave event at all.

I could probably cludge something together with mousemove on the entire paragraph, but that seems really ugly. I don’t think I can use some kind of coordinated event handling to check mouseleave on both the span and the button, because there’s space between them.

My desired behavior is to have a (DOM-based or calculated) invisible box that includes both the span and the button, and to listen for the mouse leaving that box, at which time I can hide the button. What’s the right way to do this?

  • 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-25T21:49:46+00:00Added an answer on May 25, 2026 at 9:49 pm

    You could put the hiding on a timer and start the timer when the mouse leaves your <span>:

    var timer = null;
    $('span.editable').mouseleave(function() {
        if(timer)
            clearTimeout(timer);
        timer = setTimeout(function() {
            $('#edit-this').hide();
            timer = null;
        }, 2000);
    });
    

    And then cancel the timer when the mouse enters #edit-this and set up a one-time event handler to hide #edit-this when the mouse leaves it:

    $('#edit-this').mouseover(function() {
        if(timer)
            clearTimeout(timer);
        timer = null;
    
        var $this = $(this);
        $this.one('mouseleave', function() {
            $this.hide();
        });
    });
    

    You’ll also want to clear the timer in your mouseover for the span (thanks for catching this):

    $('span.editable').mouseover(function(e) {
        if(timer)
            clearTimeout(timer);
        timer = null;
        // ...
    });
    

    Demo: http://jsfiddle.net/ambiguous/pBtG8/2/

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

Sidebar

Related Questions

Application : I am working on one mid-large size application which will be used
Our application allows users to upload javascript, CSS, and HTML files. We need a
my application use 10 threads that to read a lot of html file.similar the
APPLICATION DESCRIPTION : I am a new iPhone developer. I am working on an
Application use NHibernate. I Have object A that contains set of objects B. I
My application has a complex schema for the domain entity. It is required use
Application requests KML data through AJAX from server. This data is stored in javascript
Application: WPF Application consisting of a textbox on top and a listbox below Users
Application : HTA (therefore IE) This is an application that uses SendKeys to populate
Application is written in delphi 2010 and the underlying dll is a C++ dll.

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.