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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T16:56:18+00:00 2026-06-05T16:56:18+00:00

I have some toy code for a tooltip. It works okay, except that when

  • 0

I have some toy code for a tooltip. It works okay, except that when you mouse into the tooltip it gets hidden with this logic.

I’m banging my head trying to figure out a clean way to get the tooltip to stay visible when you mouse into it, and disappear when you mouse out of both areas. Anyone have a suggestion?

See the example.

HTML

<div id="container">
    <div id="div1"></div>
    <div id="div2"></div>
</div>

Javascript

var div1 = $("#div1");
var div2 = $("#div2").hide();

var hoverTimer;
div1.mouseenter(function(e) {
    var x = e.pageX;
    var y = e.pageY;
    div1.mousemove(function(e) {
        x = e.pageX;
        y = e.pageY;
    });
    hoverTimer = window.setTimeout(function() {
        div2.css("left", x);
        div2.css("top", y);
        div2.show();
    }, 400);
});

div1.mouseleave(function(e) {
    window.clearTimeout(hoverTimer);
    div2.hide();
});

CSS

#container {
    position: relative;
}
#div1 {
    float: left;
    clear: none;
    width: 200px;
    height: 200px;
    background-color: green;
}
#div2 {
    position: absolute;
    width: 100px;
    height: 100px;
    background-color: blue;
}
  • 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-05T16:56:19+00:00Added an answer on June 5, 2026 at 4:56 pm

    You create the mousemove event, but aside from setting two variables you never actually move the tooltip. Try this instead. Note I added a 16-pixel “margin” on the mouse position – this is to make it more inline with actual tooltips, and prevents the flickering effect.

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

Sidebar

Related Questions

I have some values that are stored with core data, and I have opened
I have some animation that was created in the main timeline in an FLA
I have some sentences that I want to parse. Here is what I have
So, I'm starting to write some logic for a simple program (toy game on
First, I would like to have an easy code that creates a cookie called
I've got some code that uses type-punning to avoid having to call a member
where do i start on writing plugin test? I have written some toy plugins
http://jsfiddle.net/twG6R/8/ Ignore the fact that this is a completely toy application. If there is
I've got some code that I've been using successfully for some years to implement
I'm stuck with a Java OOP problem. I have come up with some toy

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.