Javascript IE6/7/8 change input type

后端 未结 1 1449
醉梦人生
醉梦人生 2020-12-07 04:42

The following javascript snippet will change the type of an INPUT, for instance from text to password. It\'s being used to allow users to display their password on-screen wh

相关标签:
1条回答
  • 2020-12-07 05:16

    Type is read-only in Internet Explorer (at least 6, anyway), so it's just not directly possible. As a workaround, I've had a hidden input field of the type I wanted, then when I need to switch the type, hid the old one and made the other one visible. Not as clean, but unfortunately just changing the type as far as I know isn't possible.

    An alternative method would be to use the JavaScript DOM to replace the field with the replaceChild function of a node.

    0 讨论(0)
提交回复
热议问题