很可能在浏览器的安全模型中阻止了此操作。
编辑:确实,现在在Safari中进行测试,我得到了错误
type property cannot be changed。
编辑2:这似乎是jQuery的错误。使用以下简单的DOM代码就可以了:
var pass = document.createElement('input');pass.type = 'password';document.body.appendChild(pass);pass.type = 'text';pass.value = 'Password';编辑3:直接来自jQuery来源,这似乎与IE有关(可能是bug或其安全模型的一部分,但jQuery并非特定):
// 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";



