我正在使用 jQuery 将输入字段从文本类型切换为焦点上的密码类型。此代码在 Chrome 中运行良好,但当我尝试在 IE 8 中使用它时,它只是完全删除了该字段。 IE 8 返回此错误:
This command is not supported.
jquery.min.js
Line: 16
Char: 26827
这是我使用的 HTML 代码:
<div id="reg_passdiv" style="margin-bottom: 5px;">
<input name="reg_pass" class="inputbar italic" type="text" value="Password..." onfocus="if ($(this).attr('class') == 'inputbar italic') { $(this).attr('class', 'inputbar reg'); $(this).detach().attr('type', 'password').appendTo('#reg_passdiv'); this.value = ''; $(this).focus(); }" onblur="if (this.value == '') { $(this).attr('class', 'inputbar italic'); $(this).detach().attr('type', 'text').appendTo('#reg_passdiv'); this.value = 'Password...'; }" spellcheck="false">
</div>
任何人都可以向我解释如何修复这个错误吗?谢谢!
最佳答案
这是一个历史问题,您可以在这里深入阅读:http://bugs.jquery.com/ticket/8232 .简而言之,这在旧版 IE 中根本不可行。
好处是我以“patchwelcome”的身份关闭了该票证,因此如果您认为您可以解决该问题的合理解决方案,那么我们很乐意审查和测试。
关于javascript - JQuery IE问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7297347/