There are some restrictions on modifying the type attribute of input in js. Before the input element is inserted into the document stream, its value can be modified. It is no problem under IE and FF. But if the input already exists on the page, its type attribute becomes a read-only attribute under IE and cannot be modified. It is still a readable and writable attribute under ff.
I encountered a problem today. The input box has a default value of "password", but when it gets focus, the word "password" will be removed, and it will directly change to the password type of "****" when inputting. Obviously, at the beginning, the input type was text, and later it became password type. The intuitive idea is to use js to modify the input type. But this is not feasible under IE, so I can only change my mind and write two inputs, one of text type and one of password type, to monitor onfocus and onblur events respectively. As follows: