admin管理员组文章数量:1317906
I have a textarea and I want to replace "\n" with "," in it's value.
var valuetxtarr = $("#txtarr").val();
var valuetxtarrs = valuetxtarr.replace("/\n/g",",");
alert(valuetxtarrs);
But it don't work?Why?Where I have mistake?
I have a textarea and I want to replace "\n" with "," in it's value.
var valuetxtarr = $("#txtarr").val();
var valuetxtarrs = valuetxtarr.replace("/\n/g",",");
alert(valuetxtarrs);
But it don't work?Why?Where I have mistake?
Share Improve this question edited Jun 30, 2010 at 11:29 Álvaro González 146k45 gold badges274 silver badges375 bronze badges asked Jun 30, 2010 at 11:10 user370306user370306 1- 1 Remember that jQuery is not a synonym for JavaScript. I've added the tag for you. – Álvaro González Commented Jun 30, 2010 at 11:29
2 Answers
Reset to default 23You just need to remove the quotes (otherwise it's looking for that string), like this:
var valuetxtarr = $("#txtarr").val();
var valuetxtarrs = valuetxtarr.replace(/\n/g,",");
alert(valuetxtarrs);
You can give it a try here
var valuetxtarr = $("#txtarr").val();
var valuetxtarrs = valuetxtarr.replace(/\n/g,",");
alert(valuetxtarrs);
本文标签: javascriptReplace all quotnquot with quotquotStack Overflow
版权声明:本文标题:javascript - Replace all "n" with "," - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1738358847a2080346.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论