123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <!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>
- #div1{
- width: 200px;
- height: 200px;
- background: red;
- }
- </style>
- </head>
- <body>
- <div id="div1">
- <input type="text" id="input1">
- </div>
- <script>
- var div1 = document.getElementById('div1')
- var input1 = document.getElementById('input1')
- //点击事件
- // div1.onclick = function(){
- // console.log(111111)
- // }
- //双击事件
- // div1.ondblclick = function(){
- // console.log(2222)
- // }
- //鼠标移动
- // div1.onmousemove = function(){
- // console.log(333)
- // }
- //鼠标划出
- // div1.onmouseout = function(){
- // console.log(444)
- // }
- //按下鼠标触发事件
- // div1.onmousedown = function(e){
- // console.log(555)
- // //鼠标相对于浏览器视口的坐标轴
- // // console.log(e.clientX,e.clientY)
- // }
- //松开鼠标触发事件
- // div1.onmouseup = function(){
- // console.log(111)
- // }
- // input1.onkeydown = function(e){
- // console.log(e.keyCode)
- // if(e.keyCode == 13){
- // console.log('我是回车')
- // }
- // }
- // input1.onkeyup = function(){
- // console.log('onkeyup')
- // }
- input1.onkeypress = function(){
- console.log('onkeypress')
- }
- </script>
- </body>
- </html>
|