日期:2014-05-17  浏览次数:20923 次

修改input输入框的type属性
HTML code

<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>



想要实现当鼠标焦点放在两个输入框上面的时候将输入框置空,但是清除密码的时候出了一个问题,用户输入的密码应该是 ”*****”,在IE8下确没有效果,请大侠来帮我解决一下吧,谢谢了

------解决方案--------------------
type是只读属性,不可以修改的。
只能这样了
JScript code

<script type="text/javascript"> 
function changeType(obj) { 
    obj.style.display = "none"; 
    document.getElementById("d2").style.display = ""; 
    document.getElementById("d2").focus(); 
} 
</script>

------解决方案--------------------
只读属性,怎能修改呢?
------解决方案--------------------
密码框框肯定是用type=“password”
------解决方案--------------------
刷新·············································