手机
当前位置:查字典教程网 >编程开发 >Javascript教程 >javascript搜索框点击文字消失失焦时文本出现
javascript搜索框点击文字消失失焦时文本出现
摘要:当获焦时,文本消失,失焦时文本出现无标题文档varoText=document.getElementById("text");varonof...

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

<!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搜索框点击文字消失失焦时文本出现】相关文章:

在JavaScript中处理时间之setMinutes()方法的使用

javascript相关事件的几个概念

javascript实现点击按钮弹出一个可关闭层窗口同时网页背景变灰的方法

javascript鼠标滑动评分控件完整

javascript动态创建链接的方法

javascript字符串与数组转换汇总

浅谈Javascript线程及定时机制

Javascript客户端脚本的设计和应用

JavaScript实现点击自动选择TextArea文本的方法

javascript原型模式用法实例详解

精品推荐
分类导航