Js简单实现鼠标移动,二维码的显示和隐藏
笔记
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
.nodeSmall {
width: 70px;
height: 70px;
background: url(images/er.png) no-repeat;
position: fixed;
right: 10px;
top: 40px;
}
.erweima {
position: absolute;
top: 0;
left: -150px;
}
.nodeSmall a {
display: block;
width: 50px;
height: 50px;
}
.hide {
display: none;
}
.show {
display: block;
}
</style>
</head>
<body>
<div class="nodeSmall" id="node_samll">
<a href="#"></a>
<!-- 锚定 -->
<div class="erweima hide" id="er">
<img src="images/bg.png" alt="">
</div>
</div>
<script src="common.js"></script>
<script>
//获取鼠标要进入的a标签
// 先获取最外面的div
var aObj = my$("node_samll").getElementsByTagName("a")[0];
//为a注册鼠标进入
aObj.onmouseover = function() {
my$("er").className = "erweima show";
}
//为a注册鼠标离开
aObj.onmouseout = function() {
my$("er").className = "erweima hide";
}
</script>
</body>
</html>