Use jquery to monitor changes in input numbers

<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script type="text/javascript" src="js/jquery-1.11.0.js" ></script>
<style>
#text{resize: none;outline: none;}
</style>
</head>
<body>
<textarea id="text"></textarea>
<p>Only enter < em>300 words</em></p>
<script>
//Monitor the change of the input number
$("#text").keyup(function(){
var oText=$("#text").val( ).length
$("em").text(300-oText+"words")
}) //The upgrade version exceeds the limit of characters and cannot enter $(" #text").keyup(function(){ var len=$(this).val().length if(300-len<0){   var oText=$(this).val().substring(0,300)






  $(this).val(oText)
}else{
$("em").text(300-len)
}
})
</script>
</body>
</html>

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325907560&siteId=291194637