用jQuery更改输入字段的类型$(document).ready(function() {
// #login-box password field
$('#password').attr('type', 'text');
$('#password').val('Password');});这应该会改变#password输入字段id="password")那是.type password到普通文本字段,然后填写文本“密码”。但不管用。为什么?这是表格:<form enctype="application/x-www-form-urlencoded" method="post" action="/auth/sign-in">
<ol>
<li>
<div class="element">
<input type="text" name="username" id="username" value="Prihlasovacie meno" class="input-text" />
</div>
</li>
<li>
<div class="element">
<input type="password" name="password" id="password" value="" class="input-text" />
</div>
</li>
<li class="button">
<div class="button">
<input type="submit" name="sign_in" id="sign_in" value="Prihlásiť" class="input-submit" />
</div>
</li>
</ol></form>
3 回答
吃鸡游戏
TA贡献1829条经验 获得超7个赞
type property cannot be changed
.
var pass = document.createElement('input');pass.type = 'password';document.body.appendChild(pass);pass.type = 'text';pass.value = 'Password';
// We can't allow the type property to be changed (since it causes problems in IE)if ( name == "type" && jQuery.nodeName( elem, "input" ) && elem.parentNode ) throw "type property can't be changed";
添加回答
举报
0/150
提交
取消