判斷文本中回車的數(shù)量實例:
<HTML>
<HEAD>
<title>反選</title>
<script language=javascript>
function getCount()
{
var count=document.all('TextArea1').innerHTML.split('\n').length-1;//獲取回車的個數(shù)
alert("總共有"+ count +"個回車");
}
</script>
</HEAD>
<BODY>
<textarea id="TextArea1" cols="30" rows="8"></textarea>
<input id="Button1" type="button" value="獲取" onClick="getCount()" />
</BODY>
</HTML>