每周总结7

静态注册焦点失去事件

 

复制代码
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style type="text/css">
        div{
            position: center;
            /*margin-top: 50px;*/
            /*margin-left: 400px;*/
        }
    </style>
    <script type="text/javascript">
        var onblurfun = function (){
            console.log("静态注册的失去焦点事件")
        }
    </script>
</head>
<body>
<div>
    <p>用户名:<input type="text" onblur="onblurfun()"></p>
    <p>密&nbsp;&nbsp;&nbsp;&nbsp;码:<input type="password"></p>
</div>
</body>
复制代码

动态注册失去焦点事件

 

复制代码
 window.onload = function (){
            var passwordObj = document.getElementById("password") //获取对象
            passwordObj.onblur = function (){  //对象.事件名 = function(){}
                console.log("动态注册失去焦点事件")
            }
        }
posted @ 2022-08-15 22:36  软工小蜗牛  阅读(52)  评论(0编辑  收藏  举报