cur*_*us1 4 twitter-bootstrap twitter-bootstrap-tooltip
我正在使用Web应用程序中Bootstrap 3.x中的工具提示工具来显示有用的信息。它以这种方式工作:
$('[data-toggle="tooltip"]').tooltip({
'animation': true,
'placement': 'top',
'trigger': 'hover',
'html':true,
'container': 'body'
});
Run Code Online (Sandbox Code Playgroud)
请注意,我必须使用悬停来触发工具提示。现在,我需要添加一个新的工具提示,其工具提示文本包含一个HTML链接。访问者应该可以将鼠标悬停在工具提示文本上以单击链接。
问题在于,当访问者移动鼠标时,工具提示文本会在他可以到达工具提示文本区域之前消失。
小智 6
现在正在使用工具提示。看看这是否能更好地回答您的问题。
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
}
});Run Code Online (Sandbox Code Playgroud)
<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>Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5115 次 |
| 最近记录: |