目的:鼠标在hover状态下移动到弹出层,弹出层内容不消失且可以进行其他操作
示例代码如下:
html代码如下:
<li class="hx-list_two" data-container="body" data-toggle="popover" data-placement="left" data-trigger="hover">
<a href="#">
<img src="images/fixed_tell@2x.png">
<span>电话咨询</span>
</a>
</li>
Js代码如下所示:
$(function() {
$(".hx-list_two").popover({
trigger: "manual",
html: true,
animation: false,
content: `<ul class="wehx-popover_box">
<li class="wehx-popover_item">
<a href="">
 TEL:021-56635722
</a>
</li>
<li class="wehx-popover_item">
<a href="">
 MOB:15001758537
</a>
</li>
</ul>`
}).on("mouseenter", function() {
// console.log($(".hx-flot_window li a").css)
var _this = this; // 这里的this触发的dom,需要存起来 否则在下面 .popover的逻辑中this会变为弹出的dom
$(this).popover("show");
$(".popover").on("mouseleave", function() {
$(_this).popover('hide');
});
}).on("mouseleave", function() {
var _this = this;
setTimeout(function() {
if (!$(".popover:hover").length) {
$(_this).popover("hide");
}
}, 300);
});
});
最终效果: