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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:00:19+00:00 2026-05-14T06:00:19+00:00

HTML: <a href=# rel=tooltip-1>Open Tooltip</a> <div id=tooltip-1>Tooltip Content</div> jQuery: xOffset = $(‘#tooltip-1’).height() + 10;

  • 0

HTML:

<a href="#" rel="tooltip-1">Open Tooltip</a>
<div id="tooltip-1">Tooltip Content</div>

jQuery:

xOffset = $('#tooltip-1').height() + 10;
yOffset = -30 ;  
$("a[rel=tooltip-1]").hover(function(e){             
 this.t = this.attr("href");
 $("body").append("<p id='tooltip'>"+ this.t +"</p>");
 $("#tooltip")
  .css("top",(e.pageY - xOffset) + "px")
  .css("left",(e.pageX + yOffset) + "px")
  .fadeIn("fast");  
},
function(){
 this.t = "";
 $("#tooltip").remove();
}); 
$("a[rel=tooltip-1]").mousemove(function(e){
 $("#tooltip-1")
  .css("top",(e.pageY - xOffset) + "px")
  .css("left",(e.pageX + yOffset) + "px");
});

Two Issues:

  1. Tooltip div (#tooltip-1) doesn’t hide on mouseout.
  2. Since the tooltip div will always have the same ID as REL, I’d like to modify the above jQuery so that it takes target DIV ID automatically.

Thanks in advance for your help.

  • 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-14T06:00:19+00:00Added an answer on May 14, 2026 at 6:00 am
    this.t = this.attr("href");
    

    this is a DOM node, not a jQuery wrapper: there is no attr() method.

    (I also don’t see why you’re writing to an expando t property on the node. You don’t seem to use it anywhere else.)

    $("body").append("<p id='tooltip'>"+ this.t +"</p>");
    

    Try not to make HTML strings from plain text. Any & or < characters in t and your HTML is messed up. (This is an easy way to let cross-site-scripting security holes in.) Use text() to set plain text content in an element instead.

    (Although, I’m not sure why you’re writing the # attribute value into the tooltip. Are you trying to read the HTML of the tooltip div and copy it into the p? Why not just use the tooltip div itself?)

    Tooltip div (#tooltip-1) doesn’t hide on mouseout.

    It doesn’t hide/show at all, your script isn’t touching it anywhere.

    Since the tooltip div will always have the same ID as REL

    How about putting this information in the href fragment, rather than abusing rel? Then the link actually points to the place it’s going to pop up.

    eg. something like:

    <a href="#footnote1" class="tooltip">?</a>
    
    <div id="footnote1" style="background: yellow; width: 10em;">
        Hello!
    </div>
    
    $('.tooltip').each(function() {
        var tip= $(this.hash);
        var dx= -30, dy= -tip.height()-10;
        tip.css('position', 'absolute');
        tip.hide();
    
        function position(e) {
            tip.css('left', e.pageX+dx+'px').css('top', e.pageY+dy+'px');
        }
        $(this).mousemove(position);
    
        $(this).hover(function(e) {
            position(e);
            tip.show('fast');
        }, function(e) {
            tip.hide('fast');
        });
    });
    

    (Or just use one of the many already-existing jQuery tooltip plugins.)

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

Sidebar

Ask A Question

Stats

  • Questions 381k
  • Answers 381k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer for plain text files, it's safest to move the original… May 14, 2026 at 10:17 pm
  • Editorial Team
    Editorial Team added an answer You will need to use multibyte string functions http://au.php.net/manual/en/function.mb-internal-encoding.php UTF-8… May 14, 2026 at 10:17 pm
  • Editorial Team
    Editorial Team added an answer oh yeah, that is what I meant. This is how… May 14, 2026 at 10:17 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.