Cross-browser placehold and cross-browser placehold
How to Implement the placeholder effect across browsers?
First look at the effect
The js Code is as follows:
$ ('# Username '). placeholder ({word: 'username', color: '# ddd', normalFontColor: '# f00', maxLen: 4, minLen: 2, errorBorderClass: 'errorborder', keyup_callback: function () {console. log ('keyup _ callback') ;}}); $ ('# password '). placeholder ({word: 'Enter the password', normalFontColor: '# f00', color:' # ddd '}, function () {console. log ('callback ');});
Parameter description:
| Parameter Name |
Description |
Example |
| Word |
Text Box displays text by default |
Enter Password |
| Color |
Color of text displayed by default |
'# Ddd' |
| EvtType |
Event type, that is, what event triggers the default text to disappear |
The default value is 'focal' |
| MaxLen |
The maximum number of characters that can be entered in the text box. 0 indicates no limit. |
|
| MinLen |
The minimum number of characters entered in the text box. 0 indicates no limit. |
|
| NormalFontColor |
Font color for normal text input |
'# F00' |
| ErrorBorderClass |
Class that takes effect when an error occurs |
For example, if the number of characters in the input box is smaller than minLen, the class will be applied. |
| Keyup_callback |
Keyup callback function |
|
| Blur_callback |
Callback Function with invalid focus |
|
| Focus_callback |
Callback Function for getting focus |
|
| Click_callback |
Click the callback function of the event. |
|
| Keydown_callback |
The callback function of the keydown event. |
|
Html instance
<! DOCTYPE html>
Code:
[Write link content here] (http://pan.baidu.com/s/1kTzkfeJ
Write link content here
Copyright Disclaimer: This article is an original article by the blogger and cannot be reproduced without the permission of the blogger.