laurenclark
3/23/2016 - 1:23 PM

Show/Hide password with jQuery

Show/Hide password with jQuery

        $('.container-class').each(function() {
        $(this).on('click', function() {
            var icon = $(this).find('i');
            var input = $(this).parent().find('input');
            if(icon.hasClass('fa-eye-slash')) {
                icon.removeClass('fa-eye-slash');
                icon.addClass('fa-eye');
                input.attr({type:'text'});
            } else {
                icon.removeClass('fa-eye');
                icon.addClass('fa-eye-slash');
                input.attr({type:'password'});
            }
        });
    });