js
//Change the password display state by clicking ico.
changePasswordDisplayState = function(){
if ($inputpw.attr("type") == "password") {
$inputpw.get(0).setAttribute("type", "text");
$eye.get(0).setAttribute("class", "fa fa-eye-slash");
} else {
$inputpw.get(0).setAttribute("type", "password");
$eye.get(0).setAttribute("class", "fa fa-eye");
}
}
html
先引用font的css文件
font文件下载:官网下载地址:http://www.fontawesome.com.cn/
下载后将文件夹解压到你的css目录即可
<link href ="css/font-awesome-4.7.0/css/font-awesome.css" rel="stylesheet">
<input type = "password" id = "inputpw"><a class = "fa fa-eye" id = "eye" ></a></input>