123456亲,说说你在做什么,想什么id="div_editor"id="txt_content" rows="2" cols="10"class="d-last"还能输入140字type="button" id="btn_submit" value="确定"
12345678910111213141516171819202122232425262728293031h4 {color:#B1B1B1;font-weight:100;font-size:14px;}#div_editor {width:400px;border:1px solid #A9A9A9;}#div_editor textarea {border:0px;width:398px;height:45px;outline:0px;resize:none;}#div_editor div.d-last {text-align:right;font-size:10px;color:#B1B1B1;display:none;}#btn_submit {color:white;background-color:#8AC328;width:80px;height:25px;border:1px solid #9CC868;margin:1px;}
123456789101112131415161718192021222324252627$(function() {$("#div_editor textarea").focus(function() {$(this).css("height", "60px");$("#div_editor div.d-last").show();$("#div_editor").css("borderColor", "#B4E6FA");}).blur(function() {$(this).css("height", "45px");$("#div_editor div.d-last").hide();$("#div_editor").css("borderColor", "#A9A9A9");}).keyup(function() {var c = $(this).val();if (c.length > 140) {c = c.substr(0, 140);$(this).val(c);}var last = 140 - c.length;$("#div_editor div.d-last").text("还能输入" + last + "字");})});
当用户想在一个输入框中输入一下字,但是不能输太多,这时候就要有字数限制,但是还可以时时显示还可输入多少字