28,391
社区成员
发帖
与我相关
我的任务
分享
<html>
<head>
<script type="text/javascript">
function Count(obj)
{
sp = document.getElementById("aa");
var txt = obj.innerText;
txt = txt.replace(/[^\x00-\xff]/ig, "aa");
txt = txt.replace("}", "");
txt = txt.replace("{", "");
leftNum = 300 - txt.length;
if (leftNum < 0) {
sp.style.color = "red";
}
sp.innerText = leftNum;
}
</script>
</head>
<body>
<textarea id="ta1" onkeyup="Count(this)"></textarea>
<div>还可以输入 <span id="aa">300</span> 个字符</div>
</body>
<html>