3
I rephrased the question, what I’m trying to do is the following, Goal is to do the same as IE does in inputs type password!
<style>.show_key{display:none;}</style>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script>
<script>
$(document).ready(function(){
$(".show_key").mousedown(function() {
$(".hide-pass-input").attr("type", "text")
});
$(".show_key").mouseup(function() {
$(".hide-pass-input").attr("type", "password")
});
$(".show_key").mouseout(function() {
$(".hide-pass-input").attr("type", "password")
});
$(".hide-pass-input").keyup(function(){
var num = $(".hide-pass-input").val().length;
if(num>=1){
$(".show_key").show();
}
else{
$(".show_key").hide();
}
});
});
});
</script>
<input class="hide-pass-input" name="senha" type="password" placeholder="Digite a senha" value="">
<div class="show_key">Mostrar senha</div>
Added
What I need is: the input starts with type password, and if the user is going to type and the field contains 1 or more characters the div "show_key" appears, and clicking on it change the type password to type text, if I drop show_key it returns to type password, and if I click out of the input the div "show_key" goes away, basically the function that that eye icon that some systems have does to show the password!
I thank you all.
If you put your if/Else inside an event
.change
should perform the way you want.– Máttheus Spoo
Please if you manage to send the modified code thank you I am not good at Js, I know a lot, but very little!
– Caio Lourençon