gpt4 book ai didi

twitter-bootstrap - Bootstrap : hover over the tooltip text to click a link

转载 作者:行者123 更新时间:2023-12-04 07:43:48 25 4
gpt4 key购买 nike

我在我的网络应用程序中使用 Bootstrap 3.x 中的工具提示工具来显示有用的信息。它以这种方式工作:

$('[data-toggle="tooltip"]').tooltip({
'animation': true,
'placement': 'top',
'trigger': 'hover',
'html':true,
'container': 'body'
});

请注意,我 必须使用悬停触发工具提示。现在我需要添加一个新的工具提示,它的工具提示文本包含一个 HTML 链接。访问者应该能够将鼠标悬停在工具提示文本上以单击链接。

问题是当访问者移动他的鼠标时,工具提示文本在他到达工具提示文本区域之前就消失了。

最佳答案

现在正在使用工具提示。看看这是否能更好地回答你的问题。

var originalLeave = $.fn.tooltip.Constructor.prototype.leave;
$.fn.tooltip.Constructor.prototype.leave = function(obj) {
var self = obj instanceof this.constructor ?
obj : $(obj.currentTarget)[this.type](this.getDelegateOptions()).data('bs.' + this.type)
var container, timeout;

originalLeave.call(this, obj);

if (obj.currentTarget) {
container = $(obj.currentTarget).siblings('.tooltip')
timeout = self.timeout;
container.one('mouseenter', function() {
//We entered the actual popover – call off the dogs
clearTimeout(timeout);
//Let's monitor popover content instead
container.one('mouseleave', function() {
$.fn.tooltip.Constructor.prototype.leave.call(self, self);
});
})
}
};


$('body').tooltip({
selector: '[data-toggle]',
trigger: 'click hover',
placement: 'auto',
delay: {
show: 50,
hide: 400
}
});
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- jQuery library -->
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js"></script>

<!-- Latest compiled JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script>

<p>
<button class='btn btn-primary btn-large' data-toggle="tooltip" data-html="true" title="<a href='http://www.wojt.eu' target='blank' >click me, I'll try not to disappear</a>">hover here</button>
</p>

关于twitter-bootstrap - Bootstrap : hover over the tooltip text to click a link,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44396627/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com