鼠标单击、双击事件
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>点击事件</title>
<script src="https://lib.baomitu.com/jquery/3.4.1/jquery.js"></script>
</head>
<style type="text/css">
body{
background: #BEE7E9;
width: 100%;
height: 100%;
}
#nice{
width: 100px;
height: 100px;
margin: 50px;
background: #ECAD9E;
border: 3px solid #F4606C;
border-radius: 9px;
cursor: pointer;
}
</style>
<body>
<button id="nice" onclick="clickEvent()">点击事件</button>
</body>
<script type="text/javascript">
//点击次数
var times=0;
function clickEvent(param) {
times++;
setTimeout(function() {
if(1==times){
// console.log("单击");
alert("单击");
}else if(2==times){
// console.log("双击");
alert("双击");
}
times=0;
}, 300);
}
</script>
</html>
鼠标移入、离开事件
<script type="text/javascript" >
$(document).on('mouseenter', '.imageMouse', function(){
console.log("鼠标移入");
}).on('mouseleave', '.imageMouse', function(){
console.log("鼠标离开");
});
</script>