Home > Web Front-end > JS Tutorial > body text

js modification of input type attribute and browser compatibility issues discussion and solution_javascript skills

WBOY
Release: 2016-05-16 17:43:11
Original
1099 people have browsed it

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:

Copy code The code is as follows:




< meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
Produced by Qian Yunlai|qianyunlai.com
< ;/head>







Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!