I'm going mad here.
I've got the following HTML:
<a href="#" rel="tooltip" title="A nice tooltip">test</a>
And the Bootstrap style tooltip refuses to display, just a normal tooltip.
I've got bootstrap.css working just fine, and I can see the classes in there
I've got all of the relevant JS files at the end of my HTML file:
<script src="bootstrap/js/jquery.js"></script>
<script src="bootstrap/js/bootstrap-alert.js"></script>
<script src="bootstrap/js/bootstrap-modal.js"></script>
<script src="bootstrap/js/bootstrap-transition.js"></script>
<script src="bootstrap/js/bootstrap-tooltip.js"></script>
I've looked at the source of Bootstrap's example and cannot see anything that initiates the tooltip anywhere in there. So I'm guessing it should just work, or am I missing something vital here?
I've got modals and alerts and other things working just fine, so I'm not a total moron ;)
Thanks for any help!
HTML
JQuery
This one is work for me.
in head section you need to add the following code first
Then in the body section you need to do write the following code
Lets use an example to show how the Tooltips can be added to any HTML element in your document.
NOTE:
If these tooltip samples don't work when you put them in your page, then you have another problem. You need to look at things like:
See if you are including the JS file that provides the functionality you need (not just for tooltips, but any components you use on the page).
Failure of ANY of the above items can (and often does) prevent javascript from loading and/or running, and that keeps everything nice and broken.
WORKING EXAMPLES
Let's say you have a badge, and you want it to show a tooltip when the user hovers over it.
Original HTML:
Plain Bootstrap Tooltips
If you are creating tooltips for an HTML Element, and you are using Plain Bootstrap tooltips, then you will be responsible for calling the Tooltip Initializers with your own JavaScript code.
BEFORE
AFTER
INITIALIZER
Bootstrap Template Tooltips (such as INSPINIA)
If you are using a bootstrap template (such as INSPINIA), you are including a supporting script to support the template features:
In the case of INSPINIA, the included script automatically initializes all tooltips by running the following javascript code when the document is finished loading:
Because of this, you do NOT have to initialize INSPINIA-style Tooltips yourself. But you DO have to format your elements in a specific way. The Initializer looks for HTML elements with
tooltip-demo
in theclass
attribute, then calls thetooltip()
method to initialize any child elements that have the attributedata-toggle="tooltip"
defined.For our example badge, place an outer element around it (like a
<div>
or<span>
) that hasclass="tooltip-demo"
, then place thedata-toggle
,data-placement
, andtitle
attributes for the actual tooltip within the element that is the badge. Modify the original HTML from above to look something like this:BEFORE
AFTER
INITIALIZER
Note that any child elements within the
<span class="tooltip-demo">
element will have their tooltip properly prepared. I could have three child elements, all needing tooltips, and place them within one container.Multiple Items, each with a Tooltip
The best use for this would be to add the
class="tooltip-demo"
to a<td>
or an outermost<div>
or<span>
.Plain Bootstrap Tooltips while using a Template
If you are using INSPINIA, but you don't want to add extra outer
<div>
or<span>
tags to create tooltips, you can use standard Bootstrap Tooltips without interfering with the template. In this case, you will be responsible for initializing the Tooltips yourself. However, you should use a custom value in theclass
attribute to identify your Tooltip items. This will keep your Tooltip initializer from interfering with elements affected by INSPINIA. In our example, let's usestandalone-tt
:BEFORE
AFTER
INITIALIZER
From bootstrap docs on tooltips
Tooltips are opt-in for performance reasons, so you must initialize them yourself. One way to initialize all tooltips on a page would be to select them by their data- toggle attribute:
In my particular case, it didn't work because I was including two versions of jQuery. One for bootstrap, but another one (another version) for Google Charts.
When I remove the jQuery loading for the charts, it works fine.
You must put the tooltip javascript after the html. like this :
Or use $(document).ready :
The tooltip not working because you put the tooltip html before the javascript, so they don't know if there is a javascript for the tooltip. In my opinion, the script is read from the top to the bottom.