<BODY>
<TEXTAREA id="txt" rows="10" cols="100"></TEXTAREA>
<INPUT type="button" onClick="test()">
<SCRIPT language="javascript">
function test()
{
var val = document.all.txt.value;
var tempVal = val.replace(/\r\n/g,"\n---------\n");
document.all.txt.value = tempVal;
}
</SCRIPT>
</BODY>

解决方案 »

  1.   

    是加下划线,还是多加一行----------------如果是加下划线的话:
    用这个语法试试看
    Sets or retrieves whether the text in the object has blink, line-through, overline, or underline decorations. SyntaxHTML { text-decoration : sDecoration }  
    Scripting object.style.textDecoration [ = sDecoration ] Possible ValuessDecoration String that specifies or receives one of the following values:none Default. Text has no decoration. 
    underline Text is underlined. 
    overline Text has a line over it. 
    line-through Text has a line drawn through it. 
    blink Not implemented. 
     
    <textarea name="textarea1" STYLE="text-decoration:underline">或者
    textarea1.style.text-decoration="underline";//js如果是多加一行的话就用前面两位的。