#txt{
color: gray;
}
<input type="text" value="请输入内容" id="txt"/>
document.getElementById("txt").onfocus=function(){
if(this.value=="请输入内容"){
this.value="";
this.style.color="black";
}
};
document.getElementById("txt").onblur=function(){
if(this.value.length==0){
this.value="请输入内容";
this.style.color="gray";
}
};