<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<script src="js/jquery-1.11.1.js" type="text/javascript"></script>
</head>
<style>
#sNum,#sNum2{ height:20px; border:1px solid #ccc; padding: 5px; margin:20px 40px; display: inline-block; }
#inputV{width: 100px; height: 20px; margin:20px 40px; }
#inputV2{width:200px; height:80px; margin:20px 40px; }
</style>
<body>
<span id="sNum"></span>
<input type="text" placeholder="nini" id="inputV" />
<span id="sNum2"></span>
<textarea placeholder="nini" id="inputV2"></textarea>
<script type="text/javascript" charset="utf-8">
$(function(){
var inputV = $('#inputV');
var sNum = $('#sNum').html();
var euTextLen=0;
var inputLen = inputV.val().length; function textInput(obj,objch,nums,textContent ){
$(obj).keyup(function(){
var euTextLen= $(obj).val().length;
$(objch).html(euTextLen);
if(euTextLen >= nums ){
alert(textContent);
}
})
}
textInput('#inputV','#sNum',1000,'djfkljaslkjsalk');
textInput('#inputV2','#sNum2',500,'123132132');
if(inputLen==0){
$('#sNum,#sNum2').html(euTextLen);
} })
</script>
</body>
</html>