input text 框当密码框使用(火狐下有默认值的bug)

<!DOCTYPE html>
<html>


<head>
<meta charset="utf-8" />
<title> </title>
<meta content="initial-scale=1.0,maximum-scale=1.0,width=device-width" name="viewport">
<meta name="apple-touch-fullscreen" content="YES">
<meta name="format-detection" content="telephone=no">
<meta name="apple-mobile-web-app-capable" content="yes">
<meta name="apple-mobile-web-app-status-bar-style" content="black">
<meta http-equiv="expires" content="0">
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<script type="text/javascript" src="js/jquery-1.9.1.min.js"></script>
<link rel="stylesheet" href="css/reset.css" />
<style type="text/css">
#main {
border: 1px solid red;
width: 90%;
height: 100%;
margin: 0 auto;
}
.hearder {
margin: 20px 0px;
font-size: 14px;
font-weight: bold;
color: red;
}
.dd {
color: red;
width: 200px;
height: 100px;
text-align: right;
}
input {
width: 200px;
height: 50px;
margin: 0 20px;
}
</style>
</head>


<body>
<input type="text" id="Password1" name="Password1" value="密码(6-16位字母数字组合)" maxlength="30" />
<input type="text" name="password2" id="Password2" value="确认密码" />
<script type="text/javascript">
$('#Password1').on('focus',function(){
if($(this).val()=='密码(6-16位字母数字组合)'){
$(this).val('');
$(this).attr('type','password');

}
    });
  $('#Password1').on('blur',function(){
if($(this).val()==''){
$(this).val('密码(6-16位字母数字组合)');
$(this).attr('type','text');
}
    });
    $('#Password2').on('focus',function(){
if($(this).val()=='确认密码'){
$(this).val('');
$(this).attr('type','password');
}
    });
  $('#Password2').on('blur',function(){
if($(this).val()==''){
$(this).val('确认密码');
$(this).attr('type','text');
}
    });
</script>
</body>


</html>






解决办法就是:在前面加input 元素,只有第一个有默认值

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值