大家应该都用过飞信吧?我们在费心的输入框中输入的时候,在“发送”按钮的左边有一个提示:“你还能输入X个字”。我需要实现的功能和这个差不多。只需要在文本域中输入的时候,在一边提示“你输入了X个字符”。这样就够了。以下是我自己写的一段代码,但是不能实现其功能。请各位帮我看看!!代码:<!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>
</head><body><input type="textarea" id="txt" onkeydown="call_back()"><br/>
<div id="lab"></div>
<script>

function call_back()
{
var cnt = document.getElementById("txt").value.length();
alert(cnt);
document.getElementById("lab").innerHTML = ++cnt;
}
</script></body>
</html>