您的位置:首页 > Web前端 > JQuery

jquery 实现密码框的显示与隐藏示例代码

2013-09-18 00:00 806 查看
<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")){ 
$("#passwd2").val($("#passwd").val()); 
$("#passwd").hide(); 
$("#passwd2").show(); 
}else{ 
$("#passwd").val($("#passwd2").val()); 
$("#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>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: