you can use Popper.js
<script src="JavaScript/popper.min.js"></script>
<script src="JavaScript/bootstrap.min.js"></script>
And call tooltip function:
$('document').ready(function(){
$('[data-toggle=tooltip]').tooltip();
});
After experiencing the same problem, I found this solution worked without having to add additional tag attributes outside of the Bootstrap required attributes.
HTML
<a href="#" data-toggle="tooltip" title="Title Here">Hyperlink Text</a>
JQuery
$(document).ready(function() {
$("body").tooltip({ selector: '[data-toggle=tooltip]' });
});
Hope this helps!
HTML
<a href="#" data-toggle="tooltip" title="Title Here">Hyperlink Text</a>
JQuery
$(document).ready(function() {
$('[data-toggle=tooltip]').tooltip();
});
This one is work for me.
If you are creating your html that contains the tooltip with javascript, and then inserting it into the document, you have to activate the popover/tooltip AFTER you have inserted the html into the document, not on document load...
If you do $("[rel='tooltip']").tooltip();
as other answers have suggested then you will activate tooltips only on elements that are currently there in DOM. That means if you are going to change DOM and insert dynamic content later it won't work. Also this is much less efficient because it installs event handler for individual elements as opposed to using JQuery event delegation. So the best way I've found to activate Bootstrap tooltips is this one line of code that you can place in document ready and forget about it:
$(document.body).tooltip({ selector: "[title]" });
Note that I'm using title
as selector instead of rel=title
or data-title
. This has an advantage that it can be applied to many other elements (the rel
is supposed to be only for anchors) and also it works as "fallback" for old browsers.
Also note that you don't need data-toggle="tooltip"
attribute if you are using above code.
Bootstrap tooltips are expensive because you need to handle mouse events on each of the elements. This is the reason why they haven't enabled it by default. So if you ever decide to comment out above line, your page would still work if you use title attribute.
If you are OK not to use title attribute then I would recommend using pure CSS solution such as Hint.css or check http://csstooltip.com which does not require any JavaScript code at all.
I just added:
<script src="http://getbootstrap.com/assets/js/docs.min.js"></script>
below bootstrap.min.js and it works.