html===== <textarea name="" id="txt" cols="30" rows="10"></textarea> <div id=‘show‘>剩余字符150字</div> js======= var txt=document.getElementById(‘txt‘); var show=document.getElementById(‘show‘); txt.onkeyup=function () { show.innerHTML=‘剩余字符‘+(150-(this.value.length))+‘字‘ }
时间: 2024-10-20 22:54:36