admin管理员组文章数量:1429508
Apparently you can add a Twitter Bootstrap tooltip to any element that has the .tooltip
class, like so:
$(document).ready(function() {
$("a[rel='tooltip'], .tooltip").tooltip();
});
However, adding this class to a span tag does not seem to work. Example:
<p>1 + 1 = <span class="tooltip" title="Wooo!">2</span></p>
Only links seem to work with tooltips. Example:
<p>2 + 2 = <a href="#" rel="tooltip" title="Wooo!">4</a></p>
Here's a jsFiddle to demonstrate: /
So how can I display a tooltip for text wrapped in a span?
Apparently you can add a Twitter Bootstrap tooltip to any element that has the .tooltip
class, like so:
$(document).ready(function() {
$("a[rel='tooltip'], .tooltip").tooltip();
});
However, adding this class to a span tag does not seem to work. Example:
<p>1 + 1 = <span class="tooltip" title="Wooo!">2</span></p>
Only links seem to work with tooltips. Example:
<p>2 + 2 = <a href="#" rel="tooltip" title="Wooo!">4</a></p>
Here's a jsFiddle to demonstrate: http://jsfiddle/ZznzE/
So how can I display a tooltip for text wrapped in a span?
Share Improve this question edited Jun 27, 2013 at 9:20 XåpplI'-I0llwlg'I - asked Jun 27, 2013 at 9:02 XåpplI'-I0llwlg'I -XåpplI'-I0llwlg'I - 22.5k28 gold badges107 silver badges155 bronze badges1 Answer
Reset to default 3You don't need a class="tooltip"
, but a rel="tooltip"
Like this:
<p>1 + 1 = <span rel="tooltip" title="Tip 1">2</span></p>
I updated your fiddle and it works fine now: http://jsfiddle/Xz2e7/1/
I also added a cursor: pointer
to the CSS on the span tag. For usability this is better, so people know where there is interaction on the page.
Edit:
The tooltip class is not meant for using like you want to use it. the tooltip class is taking care of the tooltip itself (making it invisible when not hovering for example).
Try this: http://jsfiddle/Xz2e7/3/
本文标签: javascriptHow to apply a Twitter Bootstrap tooltip to text wrapped in a ltspangtStack Overflow
版权声明:本文标题:javascript - How to apply a Twitter Bootstrap tooltip to text wrapped in a <span>? - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745534121a2662194.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论