藍森林首頁 | 返回主頁 | 本站地圖 | 站內搜索 | 聯繫信箱 |
 您目前的位置:首頁 > 自由軟件 > 技術交流 > 應用編程


    

藍森林 http://www.lslnet.com 2006年8月25日 8:28

能否通過onclick事件來更改文本輸入框的type屬性

<input type='text' name='password' value='請輸入您的密碼' onFocus="this.value='';this.type='password'">

有一個文本輸入框,用來讓用戶輸入密碼,希望達到的目的:

當用戶沒有輸入的時候,顯示「請輸入您的密碼」提示,當用戶將光標置入此處時,清楚剛才的提示,並將此域的type屬性變為password,我寫了上面的代碼,但是不起作用,還請各位指點。謝謝!

MSDN上說的input的type具有read/write特性,不過好像無法實現write,只有通過改寫outerHTML來實現咯~~
[html]
<input type='text' value='請輸入您的密碼' onFocus="this.outerHTML='<input type=password name=password>'">
[/html]

多謝多謝!




Copyright © 1999-2000 LSLNET.COM. All rights reserved. 藍森林網站 版權所有。 E-mail : webmaster@lslnet.com