首页 > 程序开发 > web前端 > HTML/CSS >

仿新浪微博输入效果 文本框

2011-08-30

作者:aolinks<!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...

作者:aolinks

<!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=utf-8" />
<title>无标题文档</title>
</head>

<style type="text/css">
.class{color:#ccc;}
.class_1{color:#000;}
</style>
<script language="javascript">
function $$(obj)
{
return document.getElementById(obj);
}
var str_Tag="来这里写俩句吧";
function on()
{
if($$(&#39;ly&#39;).value==&#39;&#39; || $$(&#39;ly&#39;).value==str_Tag)
{
$$(&#39;ly&#39;).innerText="";
$$(&#39;ly&#39;).className="class";
}

}
function off()
{
if($$(&#39;ly&#39;).value==&#39;&#39;)
{
$$(&#39;ly&#39;).innerText=str_Tag;
$$(&#39;ly&#39;).className="class";
}
else
$$(&#39;ly&#39;).className="class_1";
}

</script>
<body>
<textarea name="ly" id="ly" cols="" rows="" onfocus="on();" onchange="off();" class="class">来这里写俩句吧</textarea>
<input id="txtpws" type="text" class="class" onfocus="if(this.value==&#39;来这里写俩句吧&#39;) {this.value=&#39;&#39;;this.className=&#39;class&#39;}" onblur="if(!this.value){this.value=&#39;来这里写俩句吧&#39;;this.className=&#39;class&#39;;}" onkeydown="this.className=&#39;class_1&#39;;" value="来这里写俩句吧" style="width:200px;margin-top:5px;" size="28">
</body>
</html>

相关文章
最新文章
热点推荐