I am adding bootstrap tooltip to my a tag like this :
jQuery('span.arUp a').attr("data-placement", "top");
jQuery('span.arUp a').attr("data-toggle", "tooltip");
jQuery('span.arUp a').attr("data-original-title", "Tooltip on top");
and a tag looks like this :
<a rel="next" href="/?p=28" data-placement="top" data-toggle="tooltip" data-original-title="Tooltip on top">Fedrer</a>
But no tooltip is ing. Please help!!
I am adding bootstrap tooltip to my a tag like this :
jQuery('span.arUp a').attr("data-placement", "top");
jQuery('span.arUp a').attr("data-toggle", "tooltip");
jQuery('span.arUp a').attr("data-original-title", "Tooltip on top");
and a tag looks like this :
<a rel="next" href="http://roadmap.private/?p=28" data-placement="top" data-toggle="tooltip" data-original-title="Tooltip on top">Fedrer</a>
But no tooltip is ing. Please help!!
Bootstrap tooltip usage:
<a rel="next" href="http://roadmap.private/?p=28" title="Tooltip on top">Fedrer</a>
$(function(){
$('span.arUp a').tooltip({
placement: 'top'
});
});
and make sure you include the bootstrap js file.
Since you are using the data-*
, you are using the auto
mode of the tooltip, which it automatically adds itself to the elements it finds.
Since you are adding the data-*
with JS instead of directly into the HTML, you need:
.js
file AFTER your additionsor
$('span.arUp a').tooltip
after your code.If you need the tooltip
feature to work with dynamic elements, you can try this:
$(document).ready(function () {
$("body").tooltip({
selector: '[data-toggle="tooltip"]'
});
});
DEMO: http://jsfiddle/FHjVs/1/
Then, whenever an element has an attribute data-toggle="tooltip"
, a tooltip will be applied, without having to run JavaScript/jQuery code.
Reference: