请高人指教。
7 个解决方案
#1
<textarea id=pp>
aaaaaa
abbb
</textarea>
<input type=button onclick="alert(pp.rows)" value="get rows number">
aaaaaa
abbb
</textarea>
<input type=button onclick="alert(pp.rows)" value="get rows number">
#2
<textarea id=pp>
aaaaaa
abbb
</textarea>
<script>
function count(str)
{
var iCount = 0;
var iPos = 0;
while(true)
{
iPos = str.indexOf("\r\n",iPos + 1);
if( iPos != -1)
iCount++
else
break;
}
return iCount;
}
</script>
<input type=button onclick="alert(count(pp.value))" value="get rows number">
aaaaaa
abbb
</textarea>
<script>
function count(str)
{
var iCount = 0;
var iPos = 0;
while(true)
{
iPos = str.indexOf("\r\n",iPos + 1);
if( iPos != -1)
iCount++
else
break;
}
return iCount;
}
</script>
<input type=button onclick="alert(count(pp.value))" value="get rows number">
#3
针对硬回车这样就可以
<textarea name="demo" rows=10 onblur="alert(value.split('\r\n').length)">
</textarea>
处理软回车要复杂得多了
<textarea name="demo" rows=10 onblur="alert(value.split('\r\n').length)">
</textarea>
处理软回车要复杂得多了
#4
设定固定的长度后,涉及到换行时强制换行用换行符·
#5
可以允许输入硬回车,也允许软回车呀。
#6
<textarea id=pp>
aaaaaa
abbb
</textarea>
<script>
function count()
{
var x = pp.scrollHeight
alert(parseInt(x/16));
}
</script>
<input type=button onclick="count()" value="get rows number">
aaaaaa
abbb
</textarea>
<script>
function count()
{
var x = pp.scrollHeight
alert(parseInt(x/16));
}
</script>
<input type=button onclick="count()" value="get rows number">
#7
up
#1
<textarea id=pp>
aaaaaa
abbb
</textarea>
<input type=button onclick="alert(pp.rows)" value="get rows number">
aaaaaa
abbb
</textarea>
<input type=button onclick="alert(pp.rows)" value="get rows number">
#2
<textarea id=pp>
aaaaaa
abbb
</textarea>
<script>
function count(str)
{
var iCount = 0;
var iPos = 0;
while(true)
{
iPos = str.indexOf("\r\n",iPos + 1);
if( iPos != -1)
iCount++
else
break;
}
return iCount;
}
</script>
<input type=button onclick="alert(count(pp.value))" value="get rows number">
aaaaaa
abbb
</textarea>
<script>
function count(str)
{
var iCount = 0;
var iPos = 0;
while(true)
{
iPos = str.indexOf("\r\n",iPos + 1);
if( iPos != -1)
iCount++
else
break;
}
return iCount;
}
</script>
<input type=button onclick="alert(count(pp.value))" value="get rows number">
#3
针对硬回车这样就可以
<textarea name="demo" rows=10 onblur="alert(value.split('\r\n').length)">
</textarea>
处理软回车要复杂得多了
<textarea name="demo" rows=10 onblur="alert(value.split('\r\n').length)">
</textarea>
处理软回车要复杂得多了
#4
设定固定的长度后,涉及到换行时强制换行用换行符·
#5
可以允许输入硬回车,也允许软回车呀。
#6
<textarea id=pp>
aaaaaa
abbb
</textarea>
<script>
function count()
{
var x = pp.scrollHeight
alert(parseInt(x/16));
}
</script>
<input type=button onclick="count()" value="get rows number">
aaaaaa
abbb
</textarea>
<script>
function count()
{
var x = pp.scrollHeight
alert(parseInt(x/16));
}
</script>
<input type=button onclick="count()" value="get rows number">
#7
up