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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:46:55+00:00 2026-06-11T09:46:55+00:00

Here is the jquery which I am using to display a tooltip: $(document).ready(function() {

  • 0

Here is the jquery which I am using to display a tooltip:

$(document).ready(function() {
$(".toolTip").hover(
    function() {
    var div_id = $(this).attr('id').split("_")[0];  
    if($("#"+div_id).length){
          //
    } 
    $(this).append(
     '<div class="toolTipWrapper">'
        +$("#"+div_id).text()
      +'</div>'
    );
    this.width = $(this).width();
    //Get the HTML document width and height
    var documentWidth = $(document).width();
    var documentHeight = $(document).height();
    var toolTipWidth = $('.toolTipWrapper').width();
    alert(documentWidth+" "+toolTipWidth+" "+$(this).offset().left);
    if ($(this).offset().left + toolTipWidth  > documentWidth) {
        alert("COMING");
    }
    //ends
    $(this).find('.toolTipWrapper').css({left:this.width+16})
    $('.toolTipWrapper').fadeIn(300);
  },
    function() {
      $('.toolTipWrapper').fadeOut(100);
    }
  );
});

In HTML I have :  

.toolTip {
    padding-right: 20px; 
    background: url(../images/help.png) no-repeat right;
    color: #3366FF;
    position: relative;
 }
 .toolTipWrapper { 
    width: 350px;
    position: absolute;
    top: 10px;
    display: none; 
    color: #4D4D4D;
    font-size: 12px; 
    background-color: #EFF0F0; 
    border-color: #C9C9C9;
    border-width: 1px;
    border-style: solid; 
    padding: 6px 15px; 
 }

Now tooltip should shift it’s position so it is still full visible if the window is smaller. I need to shift the position of tooptip to top/left of the object being hovered. But when I check $(this).offset().left + toolTipWidth > documentWidth, I do not see condition getting true as I see these values as:

documentWidth 784   toolTipWidth 350    $(this).offset().left 383

What is wrong here?

  • 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-11T09:46:57+00:00Added an answer on June 11, 2026 at 9:46 am

    If you are using window resize , its better to get the height and width of window not document,

    $(window).height();
    $(window).width();  
    

    I think this is your problem!!

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

Sidebar

Related Questions

I'm trying to create a popup for which I am using jQuery's CSS function.Here's
Here's my jQuery snippet $(document).ready(function() { $(#button).click(function(e) { $(body).append('Source:CIA World Factbook'); }); }); I
Here is a jQuery slide function I have applied to a div on hover
I have a View in which I'm using a tooltip provided by this site:
I am using facebox which uses jQuery 1.2.1 on my website here http://www.pointclickshoot.com/beta2 The
I'm using the ' simple tip ' jQuery tooltip code on my site, which
I am currently using Jquery UI to display checkboxes, which right now, don't do
I am using jquery to display results get by json object, here for image
This is my js file in which I am using jquery to verify login
I am using the jquery tooltip and here is the code for it Javascript

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.