密码的显示和隐藏

一、input标签密码的显示与隐藏

 1 function myShow(imgId,inputId) {   /* 判断密码显示状态函数 */                
 2                         if(inputId.type=="password"){
 3                              imgId.src="images/show.png";
 4                              inputId.type="text";
 5                              imgId.title="点击隐藏密码";
 6                         }else{
 7                             imgId.src="images/hide.png";
 8                             inputId.type="password";
 9                             imgId.title="点击显示密码";
10                         }
11                     }    

 

其中imgId为小眼睛图片的id,inputId为输入框的id。通过修改input标签的type属性(text和password),达到密码显示和隐藏的效果。


$("#show1").click(function (){
myShow(show1,oldPwd);
});
$("#show2").click(function (){
myShow(show2,newPwd);
});
$("#show3").click(function (){
myShow(show3,confirmPwd);
});

对函数进行调用

 

posted @ 2019-08-07 16:33  鱼七姑娘  阅读(589)  评论(0编辑  收藏  举报