代碼:
<body>
<label id="test" onmouseover="show('test')">
你瞅啥!?過來試試!
</label>
</body>
方法一:
<script>
function show(id) {
layer.tips("左邊么么噠", "#"+id+"", {
tips: [4, "#4794ec"]
});
}
</script>
實現效果:

如圖所示,當鼠標懸浮在label標簽范圍內時,通過layer.tips彈出提示消息。其中tips:中設置為4,表示左邊有空間時在左邊彈出消息框;
也可設置為其它:
1——上方;2——右方;3——下方;
詳情可查看:https://www.layui.com/doc/modules/layer.html#tips
方法二:(通過過濾器去篩選)
$("label").not(":last").mouseover(function() {
layer.tips($(this).text(), this, {
tips: [3, "#4794ec"]
});
});
其中 .not(":last") 表示排除最后一個,整體意思是:除過最后一個label標簽外的其他所有label標簽。
