Twitter bootstrap tooltip trigger default is hover.
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 hover"
solution by @Adrian does not work on Bootstrap 3. Use following:
$('[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:
$('.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
.
you can simply pass the trigger parameter :
$('[data-toggle="tooltip"]').tooltip({ trigger:'hover focus' });
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.