Skip to content

Instantly share code, notes, and snippets.

Created November 28, 2016 13:42
Show Gist options
  • Save anonymous/7e6333f240195dbce0ce81bed87db3ad to your computer and use it in GitHub Desktop.
Save anonymous/7e6333f240195dbce0ce81bed87db3ad to your computer and use it in GitHub Desktop.
var i = 0;
var newplaceholders = new Array();
var oldplaceholders = new Array();
$("input[type=password]").each(function() {
oldplaceholders.push('#' + $(this).attr('id'));
var passwordvalue = $(this).attr("placeholder");
var passwordplaceholder = "passwordplaceholder" + i;
$(this).after('<input id="passwordplaceholder' + i + '" type="text" value=' + passwordvalue + ' autocomplete="off" class="pure-input-1"/>');
newplaceholders.push('#' + 'passwordplaceholder' + i);
$(newplaceholders[i]).show();
$(oldplaceholders[i]).hide();
i++;
});
$(newplaceholders[0]).focus(function(){
$(newplaceholders[0]).hide();
$(oldplaceholders[0]).show();
$(oldplaceholders[0]).focus();
});
$(oldplaceholders[0]).blur(function(){
if($(oldplaceholders[0]).val() == '') {
$(newplaceholders[0]).show();
$(oldplaceholders[0]).hide();
}
});
$(newplaceholders[1]).focus(function(){
$(newplaceholders[1]).hide();
$(oldplaceholders[1]).show();
$(oldplaceholders[1]).focus();
});
$(oldplaceholders[1]).blur(function(){
if($(oldplaceholders[1]).val() == '') {
$(newplaceholders[1]).show();
$(oldplaceholders[1]).hide();
}
});
$(newplaceholders[2]).focus(function(){
$(newplaceholders[2]).hide();
$(oldplaceholders[2]).show();
$(oldplaceholders[2]).focus();
});
$(oldplaceholders[2]).blur(function(){
if($(oldplaceholders[2]).val() == '') {
$(newplaceholders[2]).show();
$(oldplaceholders[2]).hide();
}
});
@FrankFang
Copy link

<input type=password placeholder=xxxx>
<script>
if(document.all){
  alert('升级浏览器好不好?')
}
</script>

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