登录用户密码的显示与隐藏(样式自行定义,仅写了简单的代码):
html部分:
<divclass="form-group"><imgsrc="img/yonghu.png"/><inputtype="text"name=""class="form-control input_item"id=""placeholder="请输入账号"required></div>
<divclass="form-group"><imgsrc="img/mima.png"alt=""/><inputtype="password"name=""class="form-control input_item "id="pwd"placeholder="请输入密码"required><imgsrc="img/eyes_hide.png"alt=""id="eyesHide"><imgsrc="img/eyes_show.png"alt=""id="eyesShow"></div>
js部分:
$("#eyesHide").click(function(){if($("#pwd").attr("type")=="password"){$("#pwd").attr('type','text');$("#eyesShow").show();$("#eyesHide").hide();}});$("#eyesShow").click(function(){if($("#pwd").attr("type")=="text"){$("#pwd").attr('type','password');$("#eyesShow").hide();$("#eyesHide").show();}});
最终结果:
如果觉得《登录页面的密码的显示与隐藏》对你有帮助,请点赞、收藏,并留下你的观点哦!