From the Internet to find the code, self-encapsulated a bit ( premise: reference jquery library )
Html:
1 <Divclass= "box"> 2 <Divclass= "IPT1" ><inputtype= "text"ID= "User"value= "Name" ></Div>3 <Divclass= "Ipt2" ><inputtype= "text"ID= "Tel"value= "Phone"></Div>4 <inputtype= "Submit"class= "Submit"value= "Confirm">5 </Div>
Javascript:
1 function Inputstylechange (id,p,c1,c2) {2 //function3 var placeholder = p;4 var inputname = ID;5 Inputname.onfocus = function () {6 if (this.value = = placeholder) {7 this.value = ";8 this.style.color = C1;9 }Ten }; One Inputname.onblur = function () { A if (!this.value) { - this.value = placeholder; - this.style.color = C2; the } - }; - - if (Inputname.value = = placeholder) { + inputname.style.color = C2; - } + } A at $ (function) { - Inputstylechange ($ (' #tel ') [0], ' phone ', ' #323232 ', ' #b4b4b4 '); - //Call function - // Modify default display text to correspond to HTML form default text -})
Input font color change JS (ie compatible)