Created
January 16, 2022 06:01
-
-
Save cesjam7/d3717cc8055aa2a988a4bd954b6beb29 to your computer and use it in GitHub Desktop.
Ocultar y mostrar contraseña
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css"> | |
<div class="contrasena"> | |
<input type="password" id="contrasena"> | |
<i class="fa fa-eye" id="mostrar"></i> | |
</div> | |
<script src="https://code.jquery.com/jquery-2.2.4.min.js"></script> | |
<script> | |
$(function($) { | |
$('#mostrar').click(function() { | |
if ($(this).hasClass('fa-eye')) { | |
$('#contrasena').attr('type', 'text'); | |
$('#mostrar').attr('class', 'fa fa-eye-slash'); | |
} else { | |
$('#contrasena').attr('type', 'password'); | |
$('#mostrar').attr('class', 'fa fa-eye'); | |
} | |
}) | |
}) | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment