input [type = "password"]があるテキストボックスのプレースホルダーテキスト(パスワードを入力)を表示しようとしています。ここで、input [type="password"]を input[type= "text"]に変更してプレースホルダーを表示しようとしています。ユーザーがテキストボックスをクリックすると、 input [type="text"]が再びに変更されます。 input [type="password"]。ここでは機能していませんスクリプトを確認してください
私のjsfiddleはここにあります
function setupPasswordPlaceholder(thisEl)
{
if('' !== thisEl.attr("alt"))
{
if('' === thisEl.val())
{
thisEl.val(thisEl.attr("alt"));
thisEl.removeAttr("type");
thisEl.attr('type','text');
thisEl.css({'font-weight':'normal','font-size':'10pt','color':'#999','font-family': '"lucida grande", tahoma, verdana, arial, sans-serif'});
}
thisEl.focus(function()
{
if(thisEl.val() == thisEl.attr("alt"))
{
thisEl.val("");
thisEl.removeAttr("type");
thisEl.attr('type','password');
thisEl.css({'color': '#18A505','font-size': '10pt','font-weight':'normal'});
}
});
thisEl.focusout(function()
{
if('' === thisEl.val())
{
thisEl.val(thisEl.attr("alt"));
thisEl.removeAttr("type");
thisEl.attr('type','text');
thisEl.css({'font-weight':'normal','font-size':'10pt','color':'#999','font-family': '"lucida grande", tahoma, verdana, arial, sans-serif'});
}
});
}
}
$("input[type='password']").each(function(){
setupPasswordPlaceholder($(this));
});
</ p>