javascript搜索框点击文字消失失焦时文本出现
javascript搜索框点击文字消失失焦时文本出现
发布时间:2016-12-30 来源:查字典编辑
摘要:当获焦时,文本消失,失焦时文本出现无标题文档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教程学习
编程开发子分类