源码网商城,靠谱的源码在线交易网站 我的订单 购物车 帮助

源码网商城

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

  • 时间:2022-01-07 15:10 编辑: 来源: 阅读:
  • 扫一扫,手机访问
摘要:javascript搜索框点击文字消失失焦时文本出现
当获焦时,文本消失,失焦时文本出现
<!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>
  • 全部评论(0)
联系客服
客服电话:
400-000-3129
微信版

扫一扫进微信版
返回顶部