网页前端设计

http://www.86y.org

搜索文章

文本框特效

用声音读出全文关注我吧
 2010/12/21 15:40:34 阅读次数:7507

直接贴代码了!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=gb2312" />
<title>文本框特效</title>
<style>
.searchinp{padding:2px 2px;height:17px;width:290px;font-size:12px;}
.f_000{color:#000;}
.f_999{color:#999;}
</style>
<script>
function $(objectId) {
if(document.getElementById && document.getElementById(objectId)) {
    return document.getElementById(objectId);// W3C DOM
    } else if (document.all && document.all(objectId)) {
        return document.all(objectId);// MSIE 4 DOM
    } else if (document.layers && document.layers[objectId]) {
        return document.layers[objectId];// NN 4 DOM.. note: this won't find nested layers
    } else {
        return false;
    }
}
function addEvt(tab)
{
	$(tab).className="searchinp f_999";
	$(tab).onclick =function std()
	{			
		if($(tab).value=="请输入您的问题关键词 比如:‘忘记密码’?")
		{
			$(tab).className="searchinp";
		 	$(tab).value=""; 
		}
	}
	$(tab).onblur =function std()
	{	
		var str=$(tab);
		if(str.value.length==0)
		{
			$(tab).className="searchinp  f_999";
			str.value="请输入您的问题关键词 比如:‘忘记密码’?"; 
		}
	}
	
}
</script>
</head>
<body>
<input value="请输入您的问题关键词 比如:‘忘记密码’?" id="search_content" type="text" class="searchinp f_999">
<script>addEvt("search_content");</script>
</body>
</html>

大家有什么问题或技术上的想法可以在此与大家分享,也可以加入前端爱好者QQ群(141999928)一起学习进步:【幸凡前端技术交流群】
0

如果您觉得本文的内容对您的学习有所帮助,捐赠与共勉,支付宝(左)或微信(右)

阅读全文内容关闭