码迷,mamicode.com
首页 > 其他好文 > 详细

输入框事件处理

时间:2018-09-09 15:00:22      阅读:133      评论:0      收藏:0      [点我收藏+]

标签:ntb   put   blur   获取   焦点   col   get   style   cti   

  • 输入框获取焦点事件:onfocus
  • 输入框失去焦点事件:onblur

代码示例:

<body>
        <input type="text" placeholder="请输入任意内容" id="input">
        <script>
          //获取DOM元素
           var input=document.getElementById("input");
           //获取焦点
           input.onfocus=function(){
             this.style.width="400px";
             this.style.height="50px";
             this.style.border=‘2px solid yellow‘;

           }
           //失去焦点
           input.onblur=function(){
            this.style.color="blue";
            this.style.width="200px";
           }
        </script>
</body>

 

输入框事件处理

标签:ntb   put   blur   获取   焦点   col   get   style   cti   

原文地址:https://www.cnblogs.com/zhang-jiao/p/9612963.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!