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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T19:02:32+00:00 2026-06-14T19:02:32+00:00

This is a follow up to my previous question . I need to place

  • 0

This is a follow up to my previous question.

I need to place Bootstrap tooltips dynamically. To do so, I need to know the position of the element which triggers the tooltip (works fine) AND the width of the tooltip which is supposed to show up:

Edit for clarification:
My tooltips are generated dynamically and then inserted into the content. If they are, for example, too close to the left edge of the screen I need to place them ‘right’ instead of ‘top’. Now I want to get the width of the tooltip to only place it ‘right’ when it would actually go out of the screen.

$('body').tooltip({
    delay: { show: 300, hide: 0 },
    selector: '[rel=tooltip]:not([disabled])',
    placement: function(tip, element) {
        var offsetLeft = $(element).offset().left;
        var offsetRight = ( $(window).width() - ( offsetLeft + $(element).outerWidth() ) );

        // need help here: how to get the width of the current tooltip?
        // currently returns "0" for all elements
        var tooltipWidth = $(tip).outerWidth();
        console.log(tooltipWidth);

        if (offsetLeft < 220) {
            return 'right';
        }
        if (offsetRight < 220) {
            return 'left';
        }
        else {
            return 'top';
        }
    }
});

Thanks in advance.

  • 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-14T19:02:33+00:00Added an answer on June 14, 2026 at 7:02 pm

    From a logically point of view it is impossible 🙂 Think about it – the tooltip calls the placement function to get its position, and then it inserts the tip to the page and style it.

    However, you can create a dummy-tip with the same features as the soon-to-come tip, and by that get the width. Like this :

    $('body').tooltip({
        delay: { show: 300, hide: 0 },
        placement: function(a, element) {
    
            //title is by tooltip moved to data-original-title
            var title=$(element).attr('data-original-title');
    
            //create dummy, a div with the same features as the tooltïp
            var dummy=$('<div class="tooltip">'+title+'</div>').appendTo('body');
            var width=$(dummy).width();
            dummy.remove();
    
            //now you have width 
            //..
            //..
    
            var position = $(element).position();
            if (position.left > 515) {
                return "left";
            }
            if (position.left < 515) {
                return "right";
            }
            if (position.top < 110){
                return "bottom";
            }
            return "top";
        },
        selector: '[rel=tooltip]:not([disabled])'
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This question follows on from a previous question which can be found here: Need
This is a follow up question from my previous one found here I need
This is a follow up question to a previous question I asked about calculating
This is a follow up from my previous question I have this code basically
This is a follow-up to my previous question . Suppose I am writing the
This is a follow-up to my previous question I would like to find a
This is a follow up to my previous question: Problem passing parameters via Iframe
This is a follow on to my previous question: JSP / servlet / IE
This is a follow on from my previous question although this is about something
This is a follow-up to my previous question . I still find it very

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.