twitter-bootstrap 关于悬停和焦点的 Twitter Bootstrap 工具提示
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13572737/
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
Twitter Bootstrap Tooltips on Hover & Focus
提问by RLeisinger
Twitter bootstrap tooltip trigger default is hover.
Twitter 引导工具提示触发器默认为悬停。
I can add data-trigger="focus" to cause the tooltip to display on focus, but how I do both hover and focus?
我可以添加 data-trigger="focus" 使工具提示显示在焦点上,但是我如何同时进行悬停和聚焦?
采纳答案by Dmitry Efimenko
solution by @Adrian does not work on Bootstrap 3. Use following:
@Adrian 的解决方案不适用于 Bootstrap 3。使用以下内容:
$('[rel=tooltip]').tooltip();
$(document).on('hover', '[rel=tooltip]', function () { $(this).tooltip('show'); });
$(document).on('focus', '[rel=tooltip]', function () { $(this).tooltip('show'); });
回答by bluetoft
have you tried data-trigger="focus hover"
你有没有尝试过 data-trigger="focus hover"
回答by MajiD
you can simply pass the triggerparameter :
您可以简单地传递触发器参数:
$('[data-toggle="tooltip"]').tooltip({ trigger:'hover focus' });
回答by Adrian Heine
triggeris a single-value property, so you have to fake either of both methods:
trigger是单值属性,因此您必须伪造两种方法中的任何一种:
$('.tooltip').tooltip({trigger: 'hover'}).each(function () {
var $this = $(this), data = $this.data('tooltip');
$this.on('focus.tooltip', $.proxy(data.enter, data))
.on('blur.tooltip', $.proxy(data.leave, data));
});
Update: Alternatively, you can use my patchto Twitter Bootstrap to make triggera multi-value property and just set it to hover focus.
更新:或者,您可以使用我对 Twitter Bootstrap 的补丁来创建trigger多值属性并将其设置为hover focus.

