javascript中判断textarea行数(包括自动与换行)未测

<textarea   rows=6   cols=20   onkeypress="check(this);"></textarea>   <script>   function   check(obj){   var   o=obj.createTextRange().getClientRects();   alert(o); }   </script>

或者

alert(document.getElementById("taxtaera的ID").value.split(//r?/n/).length);

如果规定为10行,如何判断和限制,并且把多输入或复制的行截取为10行。 <textarea   rows=6   cols=20   onkeypress="check(this);"></textarea>    <script>    function   check(obj){    var   o=obj.createTextRange().getClientRects(); if(o.length>=10){ event.returnValue=false; } }    </script>

原文地址:https://www.cnblogs.com/newsouls/p/2793111.html