JS替换文本域内的回车示例 |
本文标签:文本域,回车 复制代码 代码如下: <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> |