这是我的HTML:
<div class="col">
<input type="text" id="username" name="username" onfocus="if (this.value=='Email') this.value = ''" onblur="if (this.value=='') this.value = 'Email'" value="Email" />
</div>
<div class="col">
<input type="password" id="password" name="password" value="password" onkeypress="onEnterLogin(event);" />
</div>
如果选择用户名文本字段,如何更改密码值?
答案 0 :(得分:1)
@minitech:谢谢!这就是我所做的,它完美无缺。
<div class="col">
<input type="text" id="username" name="username" onfocus="if (this.value=='Email') this.value = ''; document.getElementById('password').value = '';" onblur="if (this.value=='') this.value = 'Email'; document.getElementById('password').value = 'password';" value="Email" />
</div>
<div class="col">
<input type="password" id="password" name="password" value="password" onkeypress="onEnterLogin(event);" />
</div>