我想将输入类型文本更改为密码。但它在ie8中不起作用。我找到了解决方案;克隆并替换输入,但克隆后 onblur 不起作用。
调试器不会破坏 OnBlur 函数。有人可以给我看看吗?
这是js代码:
$(document).ready(function () {
var input = document.getElementById("Password");
var input2 = input.cloneNode(false);
input2.id = 'password1';
input2.type = 'password';
$('#Password').focus(function () {
input.parentNode.replaceChild(input2, input);
input2.focus();
});
$('#password1').blur(function () {
if ($(this).val() == '' || $(this).val() == Passwordtxt) {
document.getElementById("password1").setAttribute("type", "text");
$(this).val(Passwordtxt);
}
});
});