When you log on to the registration function, you will encounter the need to display the user's user-selected password. How do you achieve this? Today, I will share with you a useful method. jQuery uses the type attribute of the input to implement the hidden switch function of the password display, for more information, see. Generally, we provide a requirement for users to choose whether to display their own passwords during login registration,
In this case, we will surely think that as long as the type attribute of input is dynamically changed (text display/password Hiding ):
So I used$(''#id).attr('type', 'password')
However, the results of this API are not what I think, and errors have occurred.
HTML code
Uncaught Error: type property can't be changed
This attribute cannot be modified.
So I just put my hands on googl.
However, the result I got is as follows:
HTML code
Var showPwd = $ ("# showPwd"), pwd = $ ("# pwd"); showPwd. focus (function () {pwd. show (). focus (); showPwd. hide () ;}); pwd. blur (function () {if (pwd. val () = "") {showPwd. show (); pwd. hide ();}});
In general, this method is used. Simply put, two inputs are used to switch the display back and forth to obtain the characters entered by each other!
I tried this method to implement it, and there are not many codes. But I always think it's strange that such a requirement should be implemented in this way? Certainly not.
In this case, I will check if a large factory is doing this, and some large factories are not doing this!
But Google cannot find my problem, so there is no solution!
The above section describes jQuery's function of hiding and switching passwords by changing the type attribute of input. I hope it will help you. If you have any questions, please leave a message, the editor will reply to you in a timely manner. I would like to thank you for your support for PHP chinnet!
For more information about jQuery's function of hiding and switching the password display by changing the type attribute of input, see PHP!