阅读背景:

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

来源:互联网 

!--NEWSZW_HZH_BEGIN--

当获焦时,文本消逝,失焦时文本涌现

<!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>

<!doctyp




你的当前访问异常,请进行认证后继续阅读剩余内容。

分享到: