I am passing the values from a textarea into a div as such:
$("#string").on("keyup keypress paste mouseup", function () {
var a = $('#string').val();
$('#rdonly').html(a);
});
Know I want to pass the line break, replace & with 'and' so when ever you press Return/Enter a line break appears to the div.
Here is what I have now: http://jsfiddle.net/kC4GE/
If you press enter/return, the div continues to write on the same line.
I would assume it would be something with replace()event but I can’t figure it out
To catch all the ampersands and new-line characters you need to use a global flag on your regex:
Demo: http://jsfiddle.net/kC4GE/5/