Skip to content

Instantly share code, notes, and snippets.

@SoldierCorp
Created March 26, 2014 04:54
Show Gist options
  • Save SoldierCorp/9777123 to your computer and use it in GitHub Desktop.
Save SoldierCorp/9777123 to your computer and use it in GitHub Desktop.
Input type password like Internet Explorer
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<script src="http://code.jquery.com/jquery-1.11.0.min.js"></script>
<script>
$(document).on('ready', function() {
$('#show-hide-passwd').on('click', function(e) {
e.preventDefault();
var current = $(this).attr('action');
if (current == 'hide') {
$(this).prev().attr('type','text');
$(this).removeClass('glyphicon-eye-open').addClass('glyphicon-eye-close').attr('action','show');
}
if (current == 'show') {
$(this).prev().attr('type','password');
$(this).removeClass('glyphicon-eye-close').addClass('glyphicon-eye-open').attr('action','hide');
}
})
})
</script>
<style>
.input-group {
width: 30%;
margin: 0 auto;
margin-top: 50px;
}
span {
cursor: pointer;
}
</style>
</head>
<body>
<div class="input-group">
<input class="form-control" type="password"/>
<span id="show-hide-passwd" action="hide" class="input-group-addon glyphicon glyphicon glyphicon-eye-open"></span>
</div>
</body>
</html>
@johnandrade18
Copy link

Hola una consulta trato de hacer estas funciones ya no se visualiza dejo de funcionar

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment