IE 9 / 10 input框显示placeholder

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>IE显示placeholder</title>
    <script src="../jquery.js"></script>
    <style type="text/css">
        input{

        width: 100%;

        height: 38px;

        line-height: 38px;

        box-sizing: border-box;

        background: #FFFFFF;

        border: 1px solid #CCD1DD;

        border-radius: 4px;

        padding-left: 20px;

        margin-bottom: 28px;

        }

placeholder-color{

color:#C2C2D2 ;

}

    </style>
</head>
<body>
   <input type="password" name="userpassword1" placeholder="请输入旧密码"/><br />

   <input type="password" name="userpassword1" placeholder="请输入新密码"/><br />

   <input type="password" name="userpassword1" placeholder="请再次输入新密码"/>

</body>

<script  type="text/javascript">

if(window.attachEvent){
          var pwdHolder = $("input[name='userpassword']").attr('placeholder');
          var pwdHolder1 = $("input[name='userpassword1']").attr('placeholder');
          var pwdHolder2 = $("input[name='userpassword2']").attr('placeholder');
          $("input[name='userpassword']").val(pwdHolder).addClass("placeholder-color").attr('type','text');
          $("input[name='userpassword1']").val(pwdHolder1).addClass("placeholder-color").attr('type','text');
          $("input[name='userpassword2']").val(pwdHolder2).addClass("placeholder-color").attr('type','text');
          $("input[name='userpassword']").focus(function(){
              $(this).attr('type','password');
           if($(this).val() == pwdHolder){
                  $(this).val(" ").removeClass("placeholder-color");
              }
          }).blur(function(){
              if($(this).val().trim() === " "){
                  $(this).val(pwdHolder).addClass("placeholder-color");
                  $(this).attr('type','text');
              }
          });
          $("input[name='userpassword1']").focus(function(){
              $(this).attr('type','password');
              if($(this).val() == pwdHolder1){
                  $(this).val(" ").removeClass("placeholder-color");
              }
          }).blur(function(){
              if($(this).val().trim() === " "){
                  $(this).val(pwdHolder1).addClass("placeholder-color");
                  $(this).attr('type','text');
              }
          });
          $("input[name='userpassword2']").focus(function(){
              $(this).attr('type','password');
              if($(this).val() == pwdHolder2){
                  $(this).val(" ").removeClass("placeholder-color");
              }
          }).blur(function(){
              if($(this).val().trim() === " "){
                  $(this).val(pwdHolder2).addClass("placeholder-color");
                  $(this).attr('type','text');
              }
          });
}

</script>
</html>

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值