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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:16:27+00:00 2026-05-28T01:16:27+00:00

I’m trying to create an effect similar to a tooltip with jQuery. I’m reusing

  • 0

I’m trying to create an effect similar to a tooltip with jQuery.

I’m reusing the same <div> element (id="tooltip") to display the tooltip. Therefore, I need to constantly move this <div> element every time the user moves the cursor over an element which should display a tooltip. When I use the offset() property, it works fine the first time but then if I move the mouse repeatedly from one icon to the other, the tooltip starts to jump to different locations.

You can try it out here:

http://jsfiddle.net/ZbwjQ/2/

Try moving the mouse from one icon to the other repeatedly, you’ll notice that the tooltip jumps around incorrectly. It should always appear immediately to the right of the icon which is hovered over.

  • 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-28T01:16:27+00:00Added an answer on May 28, 2026 at 1:16 am

    There are several problems in your code.

    Divs aren’t self-closing tags:

    <div />     <!-- Wrong -->
    <div></div> <!-- Good -->
    

    When you have empty divs, add the following declaration in your CSS to ensure they have a body:

    div {
      content: "";
    }
    

    The jQuery offset() function seems buggy in your case, because of your hidden #tooltip. Prefer the following code to change its offset:

    $('#tooltip').css({
      top: o.top,
      left: o.left
    });
    

    Additionally, the o‘s creation seems very useless. You just have to modify directly the offsetvariable:

    var offset = $(this).offset();
    offset.left += $(this).width();
    $('#tooltip').css({
        top: offset.top,
        left: offset.left
    });
    

    Finally, try not to access several times to the same element with a selector. jQuery will have to find your element in the whole DOM tree everytime you call it.

    var tooltip = $("#tooltip"); // Use it in mousenter/mouseleave => Avoids 2 useless selections
    
    // In your mousenter function
    var el = $(this); // Use "el" to get offset/width => 1 useless selection avoided
    

    You can find a working jsfiddle here.

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

Sidebar

Related Questions

Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I'm trying to create an if statement in PHP that prevents a single post
In my XML file chapters tag has more chapter tag.i need to display chapters
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but

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.