twitter-bootstrap 如何将 Bootstrap 工具提示添加到复选框?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/26154949/
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 21:39:05  来源:igfitidea点击:

How to add a Bootstrap tooltip to a checkbox?

twitter-bootstrapcheckboxtooltip

提问by Argle

I've successfully added Bootstrap tooltips to a learning project I'm doing. So far only applied to link tags:

我已经成功地将 Bootstrap 工具提示添加到我正在做的学习项目中。到目前为止只适用于链接标签:

<a href="#" data-toggle="tooltip" data-original-title="My Popup text">
    Foobar
</a>

But I've got some checkboxes that need some explaining. I can't find any examples of Bootstrap tooltips for checkboxes. Is this a do-able thing?

但我有一些复选框需要解释一下。我找不到任何用于复选框的 Bootstrap 工具提示示例。这是一件可行的事情吗?

If I have the following:

如果我有以下几点:

<label>
    <input type="checkbox" id="foo" /> Foobar
</label>

I tinkered a bit but got nowhere trying to add popups to the checkbox.

我修改了一下,但没有尝试向复选框添加弹出窗口。

Suggestions?

建议?

回答by Unrealist

This does not have any different method. Simply done like:

这没有任何不同的方法。简单地完成如下:

<input type='checkbox' data-toggle='tooltip' data-placement='right' data-original-title="tooltip here" class='checkbox'/>

Check if you make all tooltip element initialized via jQuery. Put this in the head:

检查是否通过 jQuery 初始化了所有工具提示元素。把这个放在head

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

And in case you didn't know, disabled checkboxes do not show tooltip. Also check if your checkboxes are disabled or not.

如果您不知道,禁用的复选框不会显示工具提示。还要检查您的复选框是否被禁用。