# 显示隐藏密码

# 效果:

# CodePen:

demo

# 代码:

超简单,就是切换 input 框的 type 类型:

function isShow() {
	let input = document.getElementById('inputId') // input的dom
	if (input.type == 'password') {
		input.type = 'text' // 显示
	} else {
		input.type = 'password' // 隐藏
	}
}
1
2
3
4
5
6
7
8