I have a problem with bootstrap's tooltip : When I click on a button, tooltip stays even if is the cursor is outside of the button. I have looked into the manual - Bootstrap's tooltip and if I'm clicking on the buttons, I see the same problem. Is there any solution to fix this? Just tried in latest FF, IE.
-
It's not working in link in my question too, let's look there. There is the same problem. – SilentCry Nov 07 '15 at 17:51
27 Answers
This is because trigger
is not set. The default value for trigger is 'hover focus'
, thus the tooltip stay visible after a button is clicked, until another button is clicked, because the button is focused
.
So all you have to do is to define trigger
as 'hover'
only. Below the same example you have linked to without persisting tooltips after a button is clicked :
$('[data-toggle="tooltip"]').tooltip({
trigger : 'hover'
})
the doc example in a fiddle -> http://jsfiddle.net/vdzvvg6o/

- 21,706
- 14
- 92
- 130

- 83,997
- 17
- 205
- 265
-
3Thank you David, that really works. I misunderstood trigger option for tooltip in last, now I'm right. – SilentCry Nov 07 '15 at 18:08
-
4@SilentCry Just keep in mind who you are targeting, triggering a "hover" might not always be easy/common. – phk Nov 07 '15 at 23:10
-
-
6@davidkonrad Mobile platforms, blind users. Might also explain why they set 'hover focus' as the default. – phk Nov 07 '15 at 23:19
-
3@phk, bootstrap has a general problem by not being mobile-first, regarding blind people we should use aria-attributes. There is BTW a great tool for testing for usability developed for the canadian authorities with several "levels" you can fulfill -> **http://achecker.ca/checker/index.php** my country does not have these standards, but it is worth keeping up to them anyway. – davidkonrad Nov 07 '15 at 23:34
-
1You might want to have a look at Karmonik Cola's answer below. It keeps showing the tooltip on focus. – David Stosik Oct 16 '16 at 05:50
-
2Thanks. I hate these kind of annoying, time consuming "little" things.. This should be the default behaviour.. – yakya Feb 06 '17 at 09:00
-
1Thanks David. It worked for me. Actually the click was happening on some browsers and OS. This fix made to behave same everywhere. – user1322977 Feb 14 '17 at 19:25
-
1Could have saved a couple of hours and unnecessary code if I had read this first. Thanks for posting! – Nimblejoe Jun 19 '17 at 20:55
-
My problem was that the data-trigger attribute was set on my element, this answer clued me in to be able to see it – Nacht Apr 17 '19 at 06:52
-
What should we do for mobile devices? I have problem with it. It won't disappear after click on button. I should tap somewhere to disappear. – kaomid Apr 28 '20 at 22:37
-
1
-
Gracia mate. I was scratching my head trying to debug this & I noticed the tooltip flickering when I was inspecting the page in the browser & then a google search landed me here. Your answer gave me something to try in `Angular` & I used `triggers='hover'` & voila, everything was running like a frog. – Junaid May 24 '21 at 11:34
-
Thank you, @davidkonrad! When I click in my link the tooltip now is hiding correctly, but do not show again if I put the mouse over the link again. FIXED: My script are erasing the content of the attribute "data-original-title" after a postback. – Paulo Costa Aug 22 '21 at 20:00
-
The best solution for me would be to find a way to change the default trigger. Having to add this settings is not a good solution because we would need to update the code everywhere we call `.tooltip()` and make sure all developers never forget to add this setting in the future. I'm telling you, they will. – Guillaume Bois Apr 04 '23 at 15:48
I know over a year old, but I couldn't get this to work with any examples here. I've had to use the following:
$('[rel="tooltip"]').on('click', function () {
$(this).tooltip('hide')
})
This also shows the tooltip again upon hover.

- 1,821
- 1
- 14
- 10
-
4This needs to be the accepted answer and also should be implemented into the bootstrap codebase. – kjdion84 Jan 30 '17 at 12:57
-
7This was extremely helpful for bootstrap tooltips placed on buttons with a trigger of 'hover' that cause asynchronous postbacks (i.e. display modal panels). Without this, the postback from the button press causes the tooltip to get "stuck" and never disappear. – bradykey Feb 23 '17 at 22:51
-
2In my case, I was disabling the submit button while an ajax action was performed. While the ajax process was running, the tooltip would remain since the button was disabled. Once the ajax process completed, the button would become "available" again. Hovering on and then off of the button would dismiss the tooltip. Nitai's solution fixed everything. The tooltip now hides upon click and still works on hover once the button becomes active again. – HPWD Sep 05 '17 at 15:13
-
1
-
1
Hi i have little solution for this issue. When other solutions doesn't work just try this one:
$('body').tooltip({
selector: '[data-toggle="tooltip"], [title]:not([data-toggle="popover"])',
trigger: 'hover',
container: 'body'
}).on('click mousedown mouseup', '[data-toggle="tooltip"], [title]:not([data-toggle="popover"])', function () {
$('[data-toggle="tooltip"], [title]:not([data-toggle="popover"])').tooltip('destroy');
});
This is solution for drag and drop too. So i hope this help someone :)

- 460
- 3
- 14
-
I was having the problem only with Telerik Kendo grid buttons. When I clicked one, the tooltiip would not hide. This solved it! – John81 May 03 '18 at 22:39
-
-
1
-
thanks, I have to add some lines because 'destroy' gives me an error: $('body').tooltip({ selector: '[data-toggle="tooltip"], [title]:not([data-toggle="popover"])', trigger: 'hover', container: 'body' }).on('click mousedown mouseup', '[data-toggle="tooltip"], [title]:not([data-toggle="popover"])', function () { var element = $(this); var tooltip = $(element).attr('aria-describedby'); $(tooltip).remove(); }); – Camila Alvarado Jun 05 '22 at 00:30
With Bootstrap 5
Tooltips are now initialized in plain/vanilla Javascript. Because I only saw JQuery options here, let me post the VERY SIMPLE and straightforward way in plain JS :
//Initialize bootstrap tooltips
var tooltipTriggerList = [].slice.call(document.querySelectorAll('[data-bs-toggle="tooltip"]'));
var tooltipList = tooltipTriggerList.map( function(tooltipTriggerEl) {
return new bootstrap.Tooltip(tooltipTriggerEl, {
trigger : 'hover'
});
});
You only need to add the "{trigger : 'hover'}" object as an option of bootstrap.Tooltip(element, options).
Source: https://getbootstrap.com/docs/5.1/components/tooltips/#usage

- 4,005
- 2
- 36
- 58

- 163
- 1
- 5
In my case the issue was reproduced only in Internet Explorer: no matter which element(input, div etc...) has tooltip- if clicked- tooltip remains shown.
found some solutions on web that recommends .hide() that tooltip on elements Click event- but it is bad idea- hovering back to the same element - keeps it hidden... in my case
$('.myToolTippedElement').on('click', function () {
$(this).blur()
})
made all the magic!!!- where .myToolTippedElement is the element that have a tooltip ofCourse...

- 644
- 8
- 20
-
Works for me too, and has the advantage over the accepted solution of keeping displaying the tooltip on focus. – David Stosik Oct 16 '16 at 05:48
-
-
This is also achievable in the HTML by adding the following:
data-trigger="hover"
<button type="button" data-toggle="tooltip" data-placement="top" data-trigger="hover" title="To re-enable scanning, click here">Text</button>

- 2,190
- 1
- 19
- 24
-
2
-
Tnx, only solution that worked for me, because i call toogleTooltip method on (mouseover) – user3746480 Nov 30 '20 at 16:20
-
2
in angular 7 with bootstrap 4 and jquery I found this and it works fine. I used dispose because it destroys does not hide the tooltip.
ngAfterViewChecked() {
$('[data-toggle="tooltip"]').tooltip({
trigger: 'hover'
});
$('[data-toggle="tooltip"]').on('mouseleave', function () {
$(this).tooltip('dispose');
});
$('[data-toggle="tooltip"]').on('click', function () {
$(this).tooltip('dispose');
});
}

- 419
- 5
- 3
-
Take note that if the tooltip is disposed rather than hidden, it will never come back upon re-hovering the element in question. – hangler Apr 04 '23 at 23:56
Working Solution
$(document).on("click",function()
{
setTimeout(function()
{
$('[data-toggle="tooltip"]').tooltip('hide');
},500); // Hides tooltip in 500 milliseconds
});

- 321
- 6
- 16
-
1While this code may answer the question, providing additional context regarding why and/or how this code answers the question improves its long-term value. – Adam Miklosi Jun 27 '19 at 08:56
-
@Adam I wasn't able to find any working solutions on the forums to hide a tooltip after clicking any , – Alpha Jun 27 '19 at 08:59
-
yeah I also found nothing worked until I added a timeout (I just used 10millis) – MalcolmOcean Oct 11 '20 at 02:31
The way I fixed this issue was by removing the tooltip in the click event function using the following code:
$("#myButton").on("click", function() {
$("div[role=tooltip]").remove();
});

- 159
- 2
- 6
-
1
-
@Vishnu: Yes. I now use both of these (the ONLY consistent solution I've found for this issue): $(".btn").on("click", function () { $("div[role=tooltip]").remove(); }); $('[data-toggle="tooltip"]').tooltip({ trigger: 'hover' }) – JonV Mar 25 '23 at 08:10
Also you can add:
onclick="this.blur()"

- 3,988
- 9
- 25
- 38

- 41
- 1
-
1how this is different from what Kamornik Cola has proposed (except for implementation without jQuery)? I suggest to add some explanation for the answer to be helpful. Best regards – YakovL Mar 22 '18 at 08:16
Try using rel="tooltip"
instead of data-toggle="tooltip"
which worked in my case. I was using data-toggle="tooltip"
and also set the trigger condition as hover which didn't work in my case. When I changed my data selector, it worked.
HTML Code:
<button id="submit-btn" type="submit" class="btn btn-success" rel="tooltip" title="Click to submit this form">Submit</button>
JS Code //Tooltip $('.btn').tooltip({ trigger: 'hover' });
This will definitely remove the stuck tooltip.

- 526
- 2
- 12
- 31
David's answer above helped to fix my problem. I had both hover and click event on the button. Firefox on MAC did behave as I wanted. That is, show tooltip when hover, do not show tooltip for click. On other browsers and OS, When I click, the tooltip appear and stay as show. Even if i move the mouse to other buttons for hover. This is what I had:
$('[data-toggle="tooltip"]').tooltip({placement: 'right', html: true});
This is the fix:
$('[data-toggle="tooltip"]').tooltip({placement: 'right', html: true, trigger: 'hover'});

- 141
- 2
- 9
If nothing works, try this. *execute when clicked on a button or any element that has the tooltip.
let tooltip = document.getElementsByClassName("tooltip");
tooltip[0].parentNode.removeChild(tooltip[0]);

- 75
- 2
- 7
-
Tried this and it work. Only problem is when added on a function and called for the second time. Resolved it by removing all tooltip child using `$.each`. – Ryan G Aug 23 '22 at 13:27
You can also use below method to hide tooltip on mouseleave, As below:
jQuery("body").on("mouseleave", ".has-tooltip", function(){
jQuery(this).blur();
});

- 29
- 3
Also you can use this way for old versions because the accepted answer didn't worked for me and I wrote this code for my self and its work well.
$(document).on('mousedown', "[aria-describedby]", function() {
$("[aria-describedby]").tooltip('hide');
});
To me, works only when I put this code. P.S.: I'm using Bootstrap 4.
$("body").tooltip({
selector: '[data-toggle=tooltip]',
trigger: 'hover'
}).on('click mousedown mouseup', '[data-toggle="tooltip"], [title]:not([data-toggle="popover"])', function () {
$('[data-toggle="tooltip"], [title]:not([data-toggle="popover"])').tooltip('hide');
});

- 11
- 2
This solution worked for me.
$('a[data-toggle="tooltip"]').tooltip({
animated: 'fade',
placement: 'bottom',
trigger: 'click'
});
$('a[data-toggle="tooltip"]').click(function(event){
event.stopPropagation();
});
$('body').click(function(){
$('a[data-toggle="tooltip"]').tooltip('hide');
});
I tried most of the solutions given in previous answers, but none of them worked for me.

- 37,420
- 30
- 139
- 188

- 375
- 4
- 8
-
Thanks. This works fine for me. But how can we additional add hover? Open tooltip through hover? – bkm Jan 16 '21 at 05:52
My problem is in DataTable. Below code works for me.
columnDefs: [
{
targets: 0, data: "id",
render: function (data, type, full, meta) {
return '<a href="javascript:;" class="btn btn-xs btn-default" data-toggle="tooltip" title="Pending" data-container="body"><i class="fa fa-check"></i></a>';
}
}
],
drawCallback: function() {
$('[data-toggle="tooltip"]').tooltip();
$('[data-toggle="tooltip"]').on('click', function () {
$(this).tooltip('hide');
});
}
I had this issue with Bootstrap 4 on iPhone with Safari.
On PC/Desktop, the tooltip is working great. But when looking on an iPhone with iOS 14, after click / tap on a button, the tooltip remained visible. Also when hiding the layer.
For me, adding this code solved the issue on iPhone:
jQuery('[data-toggle="tooltip"]').tooltip({
trigger : 'hover'
});
jQuery('[data-toggle="tooltip"]').on("click", function () {
$(this).tooltip("hide");
});

- 2,413
- 1
- 22
- 14
-
1This happens with me on MacOS Chrome and your answer solved the problem for me. – ianrandmckenzie Jan 14 '21 at 01:25
If the multiple solutions/suggestions above doesn't work. I put the data-bs-* options in a nested span tag after the button tag and it works after button clicked. I may assume that other tags than span should works as well but i didn't try after I got it working.
<div>
<button type="button">
<span data-bs-toggle="tooltip" data-bs-placement="top">Button Name</span>
</button>
</div>

- 59
- 8
clear trigger and reproducing the default behavior
const el = document.getElementById('my-tooltip-el');
const tooltip = new bootstrap.Tooltip(el, {
trigger: ''
});
el.addEventListener('mouseover', () => {
tooltip.show();
})
el.addEventListener('mouseleave', () => {
setTimeout(() => tooltip.hide(), 150)
})

- 895
- 9
- 9
I'm using bootstrap tooltip in cycle.js and none of the above worked for me.
I had to do this:
return button( selector + '.btn.btn-sm',
{
hook: {
destroy: tooltipOff,
insert: toggleTooltipOn,
},
....
function toggleTooltipOn(vnode){
setupJQuery();
jQuery[0].$( vnode.elm )
.tooltip({container:'body', trigger: 'hover');
//container:body is to help tooltips not wiggle on hover
//trigger:hover is to only trigger on hover, not on click
}
function tooltipOff( vnode ){
setupJQuery();
jQuery[0].$( vnode.elm ).tooltip('hide');
}

- 6,455
- 3
- 32
- 42
This works for me :
$(document).ready(function() {
$('#save').tooltip({
trigger : 'hover'
}) ;
});
I was disabling save button dynamically then problem was.

- 1,713
- 2
- 19
- 29

- 797
- 9
- 17
In my case for this was the fix:
beforeDestroyingElement() {
$('[data-toggle="tooltip"]').tooltip('hide');
}
I wasn't obeying this rule from Bootstrap docs:
Tooltips must be hidden before their corresponding elements have been removed from the DOM.

- 193
- 1
- 8
If someone want's to setup a tooltip which will show for some time after click, here is how I did:
$('[data-toggle="tooltip"]').tooltip({
trigger : 'click'})
$('[data-toggle="tooltip"]').on('shown.bs.tooltip', function () {
$(this).tooltip('hide')
})

- 1,082
- 2
- 14
- 18
Using a forced blur() has the potention to reduce the user experience. I wouldn't do that. I found that removing the "data-original-title" as well as removing the attributes "data-toggle" and "title" worked for me.
$(id).tooltip('hide');
$(id).removeAttr("data-toggle");
$(id).removeAttr("data-original-title");
$(id).removeAttr("title");

- 270
- 1
- 6
- 20
Using delegation to make it ajax friendly,
// if you're not using turbolinks, then you can remove this parent wrapper
$(document).on('turbolinks:load'), function() {
// enable tooltip with delegation to allow ajax pages to keep tooltip enabled
$('body').tooltip({
select: "[data-toggle='tooltip']"
});
// remove old tooltip from sticking on the page when calling ajax with turbolinks
$('body').on('click', "[data-toggle='tooltip']", function() {
$(this).tooltip('dispose');
});
});

- 10,818
- 4
- 59
- 65