到目前为止,我已经完成了第一部分,我成功地使用以下JavaScript将输入类型从文本更改为密码:
function replaceT(obj) {
var newO = document.createElement('input');
newO.setAttribute('type', 'password');
newO.setAttribute('class', 'textbox');
newO.setAttribute('name', obj.getAttribute('name'));
obj.parentNode.replaceChild(newO, obj);
newO.focus();
}
以及ASP代码:
<asp:TextBox ID="txtPassword" runat="server" SkinID="txtLogin" value="Password..." TabIndex="2" onfocus="replaceT(this)"></asp:TextBox>
我想要的是第二部分。如何在onblur事件中返回"Password..."值。
简而言之,我想要实现类似Facebook的密码文本框。一个在IE上运行的占位符属性。
在
focus()
之前,它是这样的:然后聚焦后:
然后返回到此
onblur()
:谢谢。
附言:
我想使用纯javascript实现,不使用jQuery,并且我正在使用IE 7+。