简体   繁体   English

标签上的Bootstrap工具提示不起作用

[英]Bootstrap tool tip on label not working

When I hover over the label bootstrap tool tip does not work like the way on the javascript tool tip examples http://getbootstrap.com/javascript/#tooltips 当我将鼠标悬停在标签引导程序工具提示上时,它无法像javascript工具提示示例中的方式那样工作: http://getbootstrap.com/javascript/#tooltips

I am trying to get my tool tip label to work on the same way as the top button tool tip example. 我正在尝试使我的工具提示标签以与顶部按钮工具提示示例相同的方式工作。

For some reason on my example it only shows the default way. 由于我的示例中的某些原因,它仅显示默认方式。 How can I get my label to show tool tip like bootstrap tool tip top example? 如何获得标签来显示工具提示,例如引导工具提示顶部示例?

My example http://codepen.io/riwakawebsitedesigns/pen/KhDAz 我的示例http://codepen.io/riwakawebsitedesigns/pen/KhDAz

<div class="form-group required">
<label class="col-sm-2 control-label" for="input-url"><span data-toggle="tooltip" data-html="true" title="Test Tool Tip">URL</span></label>
<div class="col-sm-10">
<input type="text" name="config_url" value="" placeholder="" id="input-url" class="form-control" />
</div>
</div>

<br/><br/><br/>
Sample Button test.
<button type="button" class="btn btn-default" data-toggle="tooltip" data-placement="top" title="Tooltip on top">Tooltip on top</button>

You need to import the bootstrap js first and then you can add the tooltip functionality in your javascript with $("[data-toggle='tooltip']").tooltip(); 您需要先导入bootstrap js,然后可以使用$("[data-toggle='tooltip']").tooltip();在JavaScript中添加工具提示功能$("[data-toggle='tooltip']").tooltip(); .

http://codepen.io/anon/pen/LewqF http://codepen.io/anon/pen/LewqF

The other answers are correct in saying you need this $('.btn-default, .test').tooltip() to make the tooltip work. 其他答案是正确的,说您需要此$('.btn-default, .test').tooltip()才能使工具提示正常工作。 However another problem you are having is that codepen includes jquery last, so your bootstrap js cannot attach itself to jquery so the .tooltip() function is not available when you try to call it. 但是,您遇到的另一个问题是codepen最后包含了jquery,因此您的bootstrap js无法将自身附加到jquery,因此当您尝试调用.tooltip()函数时不可用。

Use something like bootply.com or jsfiddle.net instead because you have much greater control over js file inclusion and execution order. 请改用bootply.comjsfiddle.net之类的名称 ,因为您可以更好地控制js文件的包含和执行顺序。

You just need to add this code snippet in your JS 您只需要在JS中添加此代码段

<script>
    $(function () {
        $("[data-toggle='tooltip']").tooltip();
    });
</script>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM