複製代碼代碼如下:
<html>
<head>
<title>無標題文檔</title>
<script type="text/javascript">
function aa()
{
s=form1.t1.value;
s=s.replace(//n|/r/g,"");// 加上g是全局替換,不加只替換第一個是回車、是換行符
form1.t1.value=s;
}
</script>
</head>
<body>
<form name="form1">
<textarea name="t1" style="height: 74px"></textarea>
<input type="button" value="aa" onclick="aa()">
</form>
</body>
</html>