// layer.tips(html,that, {tips: [箭头, '弹窗背景颜色'],time: 定时消失,area: ['宽', '高'],}); $(document).on('click', function (event) { if (!$(event.target).closest('.Tips_box').length && !$(event.target).is('.Tips_box')) { layer.closeAll(); } }); $('.Tips_box').on('click', function (event) { event.stopPropagation(); var that = this; console.log(that, 'that') let html = ''; html += "<div class='tab_title'><div>数据字典操作提示</div></div>"; html += "<div class='Tips_boxs'><div class='Tips_box_dot'></div><div>鼠标右键点击添加表</div></div>"; html += "<div class='Tips_boxs'><div class='Tips_box_dot'></div><div>双击表名对表名进行编辑</div></div>"; html += "<div class='Tips_boxs'><div class='Tips_box_dot'></div><div>引出连线的为主表</div></div>"; table = layer.tips(html, that, { tips: [3, '#fff'], time: 3000, area: ['390px', '160px'], }); // $('.layui-layer-content').css('height', '368px'); //火狐兼容 }); 如何改为鼠标悬停tips不消失
时间: 2023-12-24 17:04:32 浏览: 94
您可以将 `time` 参数的值设置为 0,这样提示框就不会自动消失了。然后可以在 `$('.Tips_box').on('mouseenter', function (event) { ... })` 中添加鼠标悬停事件,将提示框的显示状态设置为显示,`$('.Tips_box').on('mouseleave', function (event) { ... })` 中添加鼠标离开事件,将提示框的显示状态设置为隐藏,这样就可以实现鼠标悬停tips不消失的效果。下面是修改后的代码:
```
// layer.tips(html,that, {tips: [箭头, '弹窗背景颜色'],time: 定时消失,area: ['宽', '高'],});
$(document).on('click', function (event) {
if (!$(event.target).closest('.Tips_box').length && !$(event.target).is('.Tips_box')) {
layer.closeAll();
}
});
$('.Tips_box').on('mouseenter', function (event) {
var that = this;
console.log(that, 'that')
let html = '';
html += "<div class='tab_title'><div>数据字典操作提示</div></div>";
html += "<div class='Tips_boxs'><div class='Tips_box_dot'></div><div>鼠标右键点击添加表</div></div>";
html += "<div class='Tips_boxs'><div class='Tips_box_dot'></div><div>双击表名对表名进行编辑</div></div>";
html += "<div class='Tips_boxs'><div class='Tips_box_dot'></div><div>引出连线的为主表</div></div>";
table = layer.tips(html, that, {
tips: [3, '#fff'],
time: 0,
area: ['390px', '160px'],
});
});
$('.Tips_box').on('mouseleave', function (event) {
layer.close(table);
});
```
阅读全文