123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>事件演示</title>
- </head>
- <body>
- <form id="userForm" action="https://www.baidu.com" >
-
- <input id="username" onblur="onBlur(this)" type="text" >
- <input type="submit" value="输入框提交">
- <button onsubmit="userFormSubmit()" >按钮提交</button>
- </form>
- <script>
- function userFormSubmit (){
- console.log("提交")
- return false;
- }
- let userForm = document.getElementById("userForm");
- userForm.onsubmit = userFormSubmit;
-
- window.onload = function (){
- let ins = document.getElementById("username");
- ins.onfocus = function (){
- console.log("获取焦点")
- }
- }
- function onBlur(t){
-
- console.log(t)
- }
- </script>
- </body>
- </html>
|