Usage: Enter the default value of the prompt in the text box. Also, when editing, the changed value is displayed, and the previous value is not displayed. You can also set the CSS style when adding verification: view Code 1 <style type = "text/css">
2 body
3 {
4 font: normal 12px/17px Arial;
5}
6 div
7 {
8 padding: 2px;
9 width: 240px;
10}
11 input, textarea
12 {
13 width: 12em;
14 border: 1px solid # FFDEAD;
15}
16. focus
17 {
18 border: 1px solid # f00;
19 background: # F5FFFA;
20}
21 </style>
22
23
Jquery code:
View Code 1 $ (function (){
2 $ (": input"). bind ("focus", function (){
3 $ (this). addClass ("focus ");
4 if ($ (this). val () = this. defaultValue ){
5 $ (this). val ("");
6}
7 });
8 $ (": input"). bind ("blur", function (){
9 $ (this). removeClass ("focus ");
10 if ($ (this). val () = ''){
11 $ (this). val (this. defaultValue );
12}
13 });
14 });