在我的web应用程序的登录表单中,我使用jQuery交换密码字段的文本字段,一旦它获得焦点。它的工作无处不在,除了IE8(和,我假设,下面 - 尽管我没有检查)jQuery交换文本字段的密码字段不工作在IE8
var originalField = $(this); // Original field
var newField = $(this).clone(); // New field, cloned from the old one
newField.attr("type", "password"); // Change the new field's type to password
newField.insertBefore(originalField); // Insert the new field
originalField.remove(); // Remove the old one
newField.attr("id", "password"); // Give new field the id "password" (for CSS)
newField.select(); // Bring focus to the new field
的思考?
编辑:对不起,我没有指定,但IE中的“不工作”意味着该领域根本没有被取代。当我在IE中输入密码字段时,我可以阅读它的内容。
编辑2:下面是用HTML和JS的小提琴:http://jsfiddle.net/franktisellano/v5D9W/3/
为什么它不是在IE8的工作?它不克隆该元素,它是否不插入克隆?它错误吗? –
它究竟做什么而不是工作? newField.select()应该是newField.focus()吗? – Maxx
你能设置一个包含HTML以及JS的小提琴吗? –