[英]Twitter Bootstrap Tooltips on Hover & Focus
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”以使工具提示显示在焦点上,但我如何同时进行悬停和聚焦?
你有没有尝试过data-trigger="focus hover"
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'); });
trigger
is 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 patch to Twitter Bootstrap to make trigger
a multi-value property and just set it to hover focus
. 更新:或者,您可以将我的补丁用于Twitter Bootstrap以使
trigger
成为多值属性,并将其设置为hover focus
。
you can simply pass the trigger parameter : 你可以简单地传递trigger参数:
$('[data-toggle="tooltip"]').tooltip({ trigger:'hover focus' });
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.