<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
<style>
#box {
width: 600px;
background-color: red;
}
</style>
</head>
<body>
<div id="box"><img src="./images/cat.jpg" alt="" id="img"></div>
<script>
window.ondblclick = function () {
console.log("双击...");
}
document.oncontextmenu = function () {
console.log("右键....");
}
var box = document.getElementById("box");
box.onmousemove = function () {
console.log("鼠标在移动");
}
box.onmouseover = function () {
img.src = "./images/cat2.jpg"
}
box.onmouseout = function () {
img.src = "./images/cat.jpg"
}
box.onmousedown = function () {
this.style.backgroundColor = "orange"
}
box.onmouseup = function () {
this.removeAttribute("style")
}
</script>
</body>
</html>