bootstrap显示隐藏密码

编程知识 行业动态 更新时间:2024-06-13 00:22:35

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

更多推荐

bootstrap显示隐藏密码

本文发布于:2023-04-02 19:07:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/04f0c96d0d6e29c310f90a6d4b1040dd.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:密码   bootstrap

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!