代码:
<style type="text/css">
p{
float:left;
}
body{
width:600px;
margin: auto;
font-family:"微软雅黑 Light", Consolas;
font-size:20px;
border:2px solid #0F6;
}
textarea{
margin:15px;
}
</style>
</head>
<body>
<div>
<p> 您还能输入</p>
<p id="count" style="color:#F99">150</p>
<p>个字符的祝福信息,发送给你最想祝福的人吧!</p>
</div>
<textarea cols="70" rows="4" name='string' onkeyup="charCount(this,'count')"></textarea>
<script language="javascript">
function charCount(obj,show){
var str = obj.value;
var count = str.length;
document.getElementById(show).innerHTML = 150 - count;
}
</script>
</body>
</html>
图片: