Analog input box

 
#txt{
color: gray;
}
 
 
<Input type = "text" value = "Please enter Content" id = "txt" />
 
document.getElementById("txt").onfocus=function(){
if (this.value == "Please enter Content") {
this.value="";
this.style.color="black";
}
};
document.getElementById("txt").onblur=function(){
if(this.value.length==0){
this.value = "Please enter content";
this.style.color="gray";
}
};

Guess you like

Origin www.cnblogs.com/hellocc/p/11242498.html