bootstrap显示隐藏密码

注意:要引入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);
    }

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值