I've been trying to change the new lines to line breaks in the <TEXTAREA> but I'm failing to do so ...
I want to do this cause I take the value and append it to another <TEXTAREA> that is copied later on to the clipboard. When I copy to the clipboard, everything is set to a single line due to the new line in the <textarea>
Here is my code:
if(oInput.get(0).tagName == "TEXTAREA")
{
temp = oInput.val();
temp = temp.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
oInput.val() = temp.val();
}
Try this:
if(oInput.get(0).tagName == "TEXTAREA") {
oInput.val(function(index, value) {
return value.replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '<br />');
}
}
you can try
temp.replace(/\n/g,'<br/>');
second thing is, change oInput.val(temp);
fiddle : http://jsfiddle.net/yXhUV/
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With