Home >
Web Front-end >
H5 Tutorial >
Plug-in to support Html5 placeholder attribute under IE_html5 tutorial skills
Plug-in to support Html5 placeholder attribute under IE_html5 tutorial skills
WBOY
Release: 2016-05-16 15:47:21
Original
1456 people have browsed it
HTML5 has made many enhancements to Web Form, such as the new input type type, Form Validation, etc.
Placeholder is another new attribute added in HTML5. When this attribute is set in input or textarea, the content of the value will be displayed in the text box as a gray text prompt. When the text box gains focus, the prompt text disappear. In the past, this effect could only be achieved by using JavaScript. Firefox, Google Chrome, etc. expressed support for it, but IE was the only one that felt inconsistent!
For example:
Introducing a powerful attribute plug-in that allows IE to support placeholder. It is also compatible with other browsers that do not support placeholder. The code is as follows:
Direct Copy the code and save it as a js file for reference. No need to do any processing, super convenient!
ex: This will indeed make IE's Input display the placeholder attribute, but if there is only one input on the page Fortunately, if there are multiple inputs, if the input does not fill in any value, then its empty input will automatically fill in the value of the placeholder, causing an error. For example:
Copy code
The code is as follows:
The solution is to make your own judgment in the background. Maybe it can be solved in the above js file, and we will study it later~!
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