现在的位置: 首页 > 综合 > 正文

JS 替换文本域内的回车

2013年10月03日 ⁄ 综合 ⁄ 共 349字 ⁄ 字号 评论关闭
<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> 

 

抱歉!评论已关闭.