Skip to content

Instantly share code, notes, and snippets.

@laurenclark
Created March 23, 2016 13:23
Show Gist options
  • Save laurenclark/3c9caf2fe811d0d6a288 to your computer and use it in GitHub Desktop.
Save laurenclark/3c9caf2fe811d0d6a288 to your computer and use it in GitHub Desktop.
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'});
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment