模拟输入框

 
#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";
}
};

posted on 2019-07-25 10:09  大橙!!  阅读(100)  评论(0编辑  收藏  举报

导航