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

时间:2014-09-18    点击:82   

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

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

JS实现清除指定cookies的方法
JS合并数组的几种方法及优劣比较
JS实现的用来对比两个用指定分隔符分割的字符串是否相同
使用不同的方法结合/合并两个JS数组
js实现按Ctrl+Enter发送效果
> 返回     
地址:上海市普陀区胶州路941号长久商务中心 电话: QQ:
© Copyright 2012 上海网络 Product All Rights Reserved