Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to make bootstrap's tooltip disappear after 2 seconds on hover

I'm using the Tooltip() from Twitter-Bootstrap. When hovered over an element, a tooltip shows up. But it stays there unless you move your mouse away from it.

How can I make it dissapear after a few seconds it popped up, in stead of waiting until mouse moves away from the element?

like image 387
Quoter Avatar asked Jan 21 '14 12:01

Quoter


People also ask

How do I hide the tooltip?

To display ToolTips, select the Show ToolTips box. To hide ToolTips, clear the Show ToolTips box.

How do I show tooltip without mouseover?

You can use showAtX() method to show the toolTip over a specific dataPoint.

What is the difference between popover and tooltip?

Tooltip: use tooltips to show a short text to respondents when they hover over a word or icon. Popover: use popovers to show a longer text, or when you want to have a link to an external web page. It is shown when the respondent clicks on a word or icon.

How do I use hover tooltip?

The :hover selector is used to show the tooltip text when the user moves the mouse over the <div> with class="tooltip" .


1 Answers

Bootstrap provides methods for manipulating tooltips such as $('#element').tooltip('hide')

If you add the data-trigger='manual' attribute to your elements, you can control how the tooltip is shown or hidden.

$('.bstooltip').mouseenter(function(){
    var that = $(this)
    that.tooltip('show');
    setTimeout(function(){
        that.tooltip('hide');
    }, 2000);
});

$('.bstooltip').mouseleave(function(){
    $(this).tooltip('hide');
});

Fiddle

like image 79
Gabriel S. Avatar answered Sep 30 '22 11:09

Gabriel S.