Some requirements are to more intuitively reflect the user's ability to see how many words they have entered when entering text in the text box, and some special requirements are not more than how many words are required. The following is the implementation:
The code copy is as follows:
<html>
<head>
<script src="jquery.js" type="text/javascript"></script>
<script type="text/javascript">
function tjzs(){
var count = $("#nr").val().length;
if(count>10){
var nr = $("#nr").val().substring(0,10);
$("#nr").val(nr);
count=10;
}
$("#zs").val(count);
}
</script>
</head>
<body>
<div style="72px;width:202px;" >
<textarea id="nr" style="height:70px;width:200px;" onkeyup="tjzs()" onpropertychange="if (value.length>10) value=value.substring(0,10)"></textarea>
Word limit: <input type="text" id="zs" value="0" lang="4"/> 0/10
</div>
</body>
</html>