首页 > 代码库 > javascript 高效的textarea字数监控

javascript 高效的textarea字数监控

<input type="text" name="textfield" id="text_input" /><div>您输入的值为:<span id="test">还未输入</span></div>

<script type="text/javascript">function immediately(){ var element = document.getElementById("text_input"); if("\v"=="v") { //IE 6 7 8 element.onpropertychange = webChange; }else{ element.addEventListener("input",webChange,false); } function webChange(){ if(element.value){document.getElementById("test").innerHTML = element.value}; }}immediately();</script>

 

javascript 高效的textarea字数监控