javascript搜索框點擊文字消失失焦時文本出現
更新時間:2014年09月18日 17:23:02 投稿:whsnow
這篇文章主要介紹了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>
相關文章
JavaScript實現iframe自動高度調整和不同主域名跨域
這篇文章主要介紹了JavaScript實現iframe自動高度調整和不同主域名跨域,作者通過建立一個代理來同步高度調整,需要的朋友可以參考下2016-02-02

