How to modify the type attribute of input in js _ javascript skills

Source: Internet
Author: User
You can modify the value of the input element before inserting the document stream. It is normal in ie and ff. However, if the input already exists on the page, its type attribute becomes a read-only attribute under ie. It is not allowed to modify js to modify the type attribute of the input. You can modify the value of the input element before inserting the document stream. It is normal in ie and ff. However, 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 read/write attribute in ff.

Today, I encountered a problem. The input box has the default value "password", but the word "password" will be removed when the focus is obtained, and the input will directly change to the "***" password type. Obviously, at the beginning, the input type was text and later changed to the password type. The intuitive idea is to use js to modify the type of input. However, this is not feasible in ie, so you can only change your mind to write two inputs, one text type, one password type, and listen for onfocus and onblur events. As follows:

Note: The script code should be written to html.

The Code is as follows:






Arang Production





Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.