您的位置:首页 > 理论基础 > 计算机网络

Jquery 实现密码框的显示与隐藏【转载自http://blog.csdn.net/fengzhishangsky/article/details/11809069】

2016-12-07 11:20 821 查看
<html>
<head>
<script type="text/JavaScript" src="jQuery-1.5.1.min.js"></script>
<script type="text/javascript">
$(function(){
$("#chk").bind({//绑定一个点击事件
click: function(){
if($(this).attr("checked")){//如果选中显示密码 那么type=“text”的密码文本框就显示

//或者写为:if($("#chk").is(':checked'))
$("#passwd2").val($("#passwd").val());
$("#passwd").hide();
$("#passwd2").show();
}else{
$("#passwd").val($("#passwd2").val());//如果没有选中显示密码 那么type=“password”的密码文本框就显示 但是后面传参要注意是那个文本框中的值
$("#passwd2").hide();
$("#passwd").show();
}
}
});
});
</script>
</head>
<body>
<form name="formName">
<input id="passwd" type="password" size="24" maxlength="17" style="ime-mode: disabled; display: inline;"/>
<input id="passwd2" type="text" size="24" maxlength="17" style="ime-mode: disabled; display: none;" />
<input id="chk" type="checkbox" />显示密码
</form>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: 
相关文章推荐