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?
You 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);
var valuetxtarr = $("#txtarr").val();
var valuetxtarrs = valuetxtarr.replace(/\n/g,",");
alert(valuetxtarrs);