我想写点显示密码的按钮。 我的意思是,只需将属性“type”从密码更改为文本,当我再次单击该按钮时,密码应该隐藏。按钮“显示密码”不起作用
我的代码:
$(document).ready(function(){
var fieldType = $('input.password').attr("type");
$('.show_passwrd').on("click",function(){
if(fieldType == "password"){
$('input.password').attr("type","text");
}
else{
$('input.password').attr("type","password");
}
})
});
我没有在浏览器中的任何错误只是当我点击,什么都不做。
提供的HTML代码,以及 –