注意:要引入bootstrap的css、jquery、js
html
<div class="form-group">
<label class="col-xs-2 control-label">
原始密码:
</label>
<div class="col-xs-10">
<div class="block input-icon input-icon-right">
<input name="oldPassword" id="oldPassword" type="password" class="form-control" placeholder="请输入原始密码">
<i class="ace-icon fa fa-eye" title="显示密码" id="see_oldpwd" οnclick="seePwd(this)"></i>
</div>
</div>
</div>
js
//密码隐藏显示
function seePwd(obj){
var pwdValue = $(obj).parent().children('input:first-child').val();//获取密码值
var _type = $(obj).parent().children('input:first-child').attr('type');//获取input的type类型
if(_type == 'password'){
$(obj).parent().children('input:first-child').attr('type','text');
$(obj).attr('class','ace-icon fa fa-eye-slash');
$(obj).attr('title','隐藏密码');
}else if(_type == 'text'){
$(obj).parent().children('input:first-child').attr('type','password');
$(obj).attr('class','ace-icon fa fa-eye');
$(obj).attr('title','显示密码');
}
$(obj).parent().children('input:first-child').val(pwdValue);
}