<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<textarea name="" id="" cols="30" rows="10"></textarea><span>最多可以输入<strong style="color:red;">140</strong>个字</span>
</body>
<script src="js/jquery-1.11.3.min.js"></script>
<script>
var maxLength=140;
$("textarea").keyup(function(){
var len=$(this).val().length;
$("strong").text(maxLength-len);
if(parseInt($("strong").text())<0){
alert("最多能输入140个字");
$("strong").text("0");
var values=$(this).val().substring(0,141);
$(this).val(values);
}
})
</script>
</html>