Jquery 实现密码框的显示与隐藏【转载自http:blog.8miu.netfengzhishangskyarticledetails11809069】...

it2022-05-05  121

<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>

转载于:https://www.cnblogs.com/Lxiaojiang/p/6140438.html


最新回复(0)