能不能在textarea输入框中实时统计行的数量 <textarea name="CH" id="CH" cols="16" rows="5"></textarea>想实时显示 输入的行数 能实现吗? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <script>function fot(e){ if(e.offsetHeight<=24){ alert(1+"行") } else{ alert(((e.offsetHeight - 24)/15+1)+"行") }}</script><textarea onpropertychange="style.posHeight=scrollHeight+5" style="overflow:hidden" rows="1" cols="20" id="a"></textarea><input name="" type="button" onclick="fot(document.getElementById('a'))" /> 或者吧,每个字符判断,如果是中文字符算两个,计算总长度再除以每行最大长度<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <script language="javascript"> function showCols(o) { document.getElementById("span").innerHTML = o.value.length; var length = o.value.length; if (length && length > 0) { document.getElementById("span").innerHTML = "共" + (parseInt(length / 16) + (length % 16 > 0 ? 1 : 0)) + "行"; } } </script></head><body> <form id="form1" runat="server"> <div> <textarea name="CH" id="CH" cols="16" rows="5" onkeydown="showCols(this);"> </textarea> <span id="span"></span> </div> </form></body></html> textarea里的换行符是/r/n,不能通过换行符计算吗。 继续求教:通过js里写入的html代码,怎么添加事件? 关于css定义div问题 javascript如何接受上一页面的url的值 求一 VBS 正则表达式,不知道可行否,在线等。 showModalDialog打开的页面用select重新加载页面的问题,急! 常数中有换行符 问一个有难度的问题,急,急,急…… js字符串问题?v1.avi如何取出1,在线等待 请大家看看这段简单程序的错误! 瀑布流网页类似于淘宝商品详情页怎么加载完全 谁帮看下这段js appendchild的反向效果
function fot(e){
if(e.offsetHeight<=24){
alert(1+"行")
}
else{
alert(((e.offsetHeight - 24)/15+1)+"行")
}
}</script>
<textarea onpropertychange="style.posHeight=scrollHeight+5" style="overflow:hidden" rows="1" cols="20" id="a"></textarea>
<input name="" type="button" onclick="fot(document.getElementById('a'))" />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title> <script language="javascript">
function showCols(o) {
document.getElementById("span").innerHTML = o.value.length;
var length = o.value.length;
if (length && length > 0) {
document.getElementById("span").innerHTML = "共" + (parseInt(length / 16) + (length % 16 > 0 ? 1 : 0)) + "行";
}
}
</script></head>
<body>
<form id="form1" runat="server">
<div>
<textarea name="CH" id="CH" cols="16" rows="5" onkeydown="showCols(this);"> </textarea>
<span id="span"></span>
</div>
</form>
</body>
</html>