1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768 |
- <!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>
- #box {
- width: 700px;
- height: 700px;
- background: #f00;
- }
- #box1 {
- width: 200px;
- height: 200px;
- background: #ff0;
- }
- input {
- margin: 20px;
- }
- </style>
- </head>
- <body>
- <div id="box">
- <div id="box1"></div>
- </div>
- <input type="text">
- <script>
- var box = document.getElementById("box");
- var box1 = document.getElementById("box1");
- var inp = document.querySelector("input")
- inp.onkeydown = function() {
- console.log('键盘按下')
- }
- inp.onkeyup = function() {
- console.log('键盘抬起')
- }
- inp.onkeypress = function() {
- console.log('键盘按下并抬起事件')
- }
- // box.onclick = function() {
- // console.log("点击事件")
- // }
- // box.ondblclick = function() {
- // console.log("双击事件")
- // }
- // box.onmousedown = function() {
- // console.log("鼠标按下")
- // }
- // box.onmouseup = function() {
- // console.log("鼠标抬起")
- // }
- // box.onmousemove = function() {
- // console.log("鼠标划过")
- // }
- // box.onmouseout = function() {
- // console.log("鼠标划出")
- // }
- box.onmouseover = function() {
- console.log("鼠标划入")
- }
- </script>
- </body>
- </html>
|