Rumah >hujung hadapan web >html tutorial >修改input输入框的type属性_html/css_WEB-ITnose
<ul class="login_list" id="web_login"> <li class="login_input"> <input id="u" name="u" tabindex="2" class="input_txt" type="text" value="User name" onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}" /> </li> <li class="login_input"> <input type="text" class="input_txt2" value="Password" onfocus="if(this.value==defaultValue) {this.value='';this.type='password'}" onblur="if(!value) {value=defaultValue; this.type='text';}" /> </li></ul>
type是只读属性,不可以修改的。
只能这样了
<script type="text/javascript"> function changeType(obj) { obj.style.display = "none"; document.getElementById("d2").style.display = ""; document.getElementById("d2").focus(); } </script>
<ul class="login_list" id="web_login"> <li class="login_input"> <input id="u" name="u" tabindex="2" class="input_txt" type="text" value="User name" onFocus="this.value=''" onBlur="if(!value){value=defaultValue;}" /> </li> <li class="login_input"> <input type="text" class="input_txt2" value="Password" onfocus="changeType(this)" onblur="if(!value) {value=defaultValue; this.type='text';}" /> <input type="password" class="input_txt2" id="d2" value="" style="display:none" /> </li></ul>
只读属性,怎能修改呢?
密码框框肯定是用type=“password”
刷新·············································
type是只读属性,不可以修改的。
只能这样了
JScript code
<script> <br /> function changeType(obj) { <br /> obj.style.display = "none"; <br /> document.getElementById("d2").style.display = ""; <br /> docum…… <br /> <br /> 我已找到解决办法了,和楼主的一样,学习了,谢谢哈 </script>
<input name="" type="text" value="Password" class="inputText_1" id="tx" /><input name="" type="password" style="display:none;" id="pwd" class="inputText_1" />
<script type="text/javascript">var tx = document.getElementById("tx"), pwd = document.getElementById("pwd");tx.onfocus = function(){if(this.value != "Password") return;this.style.display = "none";pwd.style.display = "";pwd.value = "";pwd.focus();}pwd.onblur = function(){if(this.value != "") return;this.style.display = "none";tx.style.display = "";tx.value = "Password";}</script>