鼠标悬停显示提示信息
- 代码
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>测试</title>
</head>
<script src="https://cdn.staticfile.org/layui/2.7.6/layui.js"></script>
<body>
<span type="text" id="id1" onmouseover="show('测试1','id1')" onmouseleave="close_tips()">测试1</span>
<span type="text" id="id2" onmouseover='show(`<div><span style="color: chartreuse">测试2</span></div>`, "id2")' onmouseleave="close_tips()">测试2</span>
</body>
<script>
function show(msg, id){
layer.tips(''+ msg, '#'+id, {tips: [1,'black']});
}
function close_tips(){
layer.closeAll('tips');
}
</script>
</html>
- 效果图