twitter-bootstrap 将 Bootstrap 工具提示添加到 <div> 内的 <span>?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/34793800/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 23:32:32 来源:igfitidea点击:
Adding Bootstrap Tooltip to a <span> inside a <div>?
提问by Amy Neville
I have a span inside a div and I'm trying to add a Bootstrap 3 tooltip to it:
我在 div 中有一个跨度,我正在尝试向它添加 Bootstrap 3 工具提示:
<div style="display:inline-block;margin-right:10px;">
<h3>
<span class="label label-default">
Chickens: <span style="color:#fff;">3</span>
</span>
</h3>
</div>
How do I get this to work?
我如何让这个工作?
回答by Adam Buchanan Smith
I think you are asking for something like this: https://jsfiddle.net/g74Ep/471/
我想你是在要求这样的东西:https: //jsfiddle.net/g74Ep/471/
<div style="display:inline-block;margin-right:10px;margin-top: 40px;">
<h3>
<span class="label label-default" href="#" data-toggle="tooltip" title="3">
Chickens:
</span>
</h3>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>
回答by shrestha_aj
Do you mean this: https://jsfiddle.net/s294csdn/
你的意思是:https: //jsfiddle.net/s294csdn/
<div data-toggle="tooltip" title="This is a tooltip" style="display:inline-block;margin-right:10px;">
<h3>
<span class="label label-default">
Chickens: <span style="color:#fff;">3</span>
</span>
</h3>
</div>
<script>
$(document).ready(function(){
$('[data-toggle="tooltip"]').tooltip();
});
</script>

