Answer the question
In order to leave comments, you need to log in
How not to prescribe functionality for each individual tooltip in Bootstrap?
Now I am supporting a site that uses bootstrap. I use the native bootstrap component - the tooltip, but the code turns out to be too bloated - apparently I misunderstood something somewhere.
Currently, to add tooltips, I add an event trigger in javascript for each tooltip, despite the fact that the code is the same everywhere, only the selectors are different. Is there a way to avoid this?
Example code (this is for the first tooltip, for the next one it's the same only with a different selector):
$(document).ready(function(){
$('#tool').hover(
function(){
$('#tool').tooltip('show');
},function(){
$('#tool').tooltip('hide');
});
})
Answer the question
In order to leave comments, you need to log in
$(document).ready(function(){
$(".tooltip").tooltip() //tooltip общий класс для всех элементов у которых будет tooltip
})
<a href="#" data-toggle="tooltip" title="first tooltip">hover over me</a>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question