js监听密码输入框type

1、密码输入框

<input class="oaInput oaText" type="text" placeholder="请输入用户名"/>
<input class="oaInput oaPwd" type="text" placeholder="请输入密码"/>

2、默认前台显示如下

<input class="oaInput oaPwd" type="password" placeholder="请输入密码"/>

状态下:

加入js控制如下:

$('.oaPwd').bind('input propertychange',function(){
          if($(".oaPwd").val()==''){
              $('.oaPwd')[0].type="text";
          }else{
              $('.oaPwd')[0].type="password";
          }
      })
<input class="oaInput oaPwd" type="text" placeholder="请输入密码"/>

posted @ 2016-02-26 11:36  花语苑  阅读(770)  评论(0编辑  收藏  举报