js获取文本的行数时间:2023-03-09 17:25:59 <div class="txt" style="line-height:30px">我是文字<br>我是文字<br>我是文字<br>我是文字</div> <script> //高度/行高=文本行数 var rowNum=Math.round($(".txt").height()/parseFloat($(".txt").css('line-height'))); alert("当前有"+rowNum+"行"); </script>