做密码输入框经常使用点击显示密码功能,
<input id="password" class="layui-input" autocomplete="off" maxlength="15" name="password" required="" type="password" placeholder="密码为6-15位非纯数字" />
<i id="passwordeye" class="icon iconfont icon-yincangmima"></i>
图标点击js:
$('#passwordeye').click(switchPwd());
function switchPwd() {
var passwordeye = $('#passwordeye');
var showPwd = $("#password");
passwordeye.off('click').on('click',function(){
if(passwordeye.hasClass('icon-yincangmima')){
passwordeye.removeClass('icon-yincangmima').addClass('icon-xianshimima');//密码可见
showPwd.prop('type','text');
}else{
passwordeye.removeClass('icon-xianshimima').addClass('icon-yincangmima');//密码不可见
showPwd.prop('type','password');
};
});
}