javascript搜索框点击文字消失失焦时文本出现

2019-12-21,,

当获焦时,文本消失,失焦时文本出现

<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>无标题文档</title>
</head>

<body>
<input id="text" type="text" value="点我就消失"/>
<script>
var oText=document.getElementById("text");
var onoff=true;
oText.color="#000";
oText.onfocus=function(){
if(onoff){
this.value="";
this.color="red";
onoff=false;
}
}

oText.onblur=function(){
if(this.value==''){
this.color="#000";
this.value="点我就消失";
onoff=true;
}
}
</script>
</body>
</html>

您可能感兴趣的文章:

  • JavaScript实现搜索框的自动完成功能(一)
  • js实现搜索框关键字智能匹配代码
  • javascript搜索框效果实现方法
  • JS实现仿google、百度搜索框输入信息智能提示的实现方法
  • JS+CSS实现仿新浪微博搜索框的方法
  • JS实现搜索框文字可删除功能

《javascript搜索框点击文字消失失焦时文本出现.doc》

下载本文的Word格式文档,以方便收藏与打印。