<Style type = "text/css"> . Fun {margin: 0 auto; width: 1000px; overflow: hidden; box-shadow: 0 3px 6px rgba (0,0, 0, 0.1); border: solid 1px # ccc; font-family: Microsoft YaHei; overflow: hidden ;} . InputText {border: solid 1px # ccc; height: 40px; width: 200px; line-height: 40px/9; padding: 0 2px; box-shadow: inset 0 0 4px rgba (0, 0, 0.1); margin: 10px 0; outline: none; font-family: arial; font-weight: 700; text-indent: 5px; color: # 1C1C1C; display: inline-block ;} . InputText: focus {border: solid 1px # 1398FF; box-shadow: 0 0 5px rgba (0,192,255, 0.4 );} . Text {padding: 15px 0 15px 75px ;} H1 {text-align: center; padding: 10px 0; margin: 0; background:-webkit-linear-gradient (# fcfcfc, # f9f9f9) repeat; background: -moz-linear-gradient (# fcfcfc, # f9f9f9) repeat; border-bottom: solid 1px # ccc; font-weight: 400; text-shadow: 1px 1px 3px # fff;}/* Css3 background gradient */ </Style> Js code: <Script type = "text/javascript"> // JavaScript Document $ (Document). ready (function (){ Function input () { // Use each to traverse the text box $ (". InputText"). each (function (){ Var $ val = this. value; // Save the value of the current text box Var $ ss = $ (". ss"). val (); $ (This). focus (function (){ // When the focus is obtained, if the value is the default value, the value of the text box is cleared. If (this. value = $ val ){ This. value = ""; } }); $ (This). blur (function (){ // If the value is null when the focus is lost, the default value of the text box is added. If (this. value = ""){ This. value = $ val; } }); }); } Input (); }) </Script> |