js实时监听控制文本框的字数
效果图如下:
```
<div class="content">
<label class="cnd">描述:</label>
<div class="sm">
<textarea type="text" id="Introduce" name="Introduce" class="textarea" maxlength="300"
style="resize:none;" required
"javascript:CountStrByte(this, 300, 'cost_tpl_title_length');"
"javascript:CountStrByte(this, 300, 'cost_tpl_title_length');">
</textarea>
</div>
</div>
<div class="word">
<label class="cm"></label>
<div class="title2"><span id="cost_tpl_title_length"></span></div>
</div>
```
<script>
//字节统计
function CountStrByte(obj, maxlength, id) {
setTimeout(function() {
var remlength = maxlength - obj.value.length;
var wid = id;
if (remlength < 0) {
remlength = 0;
}
document.getElementById(wid).innerHTML = "您还可以输入" + remlength + "字数";
}, 100);
}
</script>