I need to edit row's cell in table with using new lines characters. Editation of these cells are make by textarea with jQuery. Problem is, that textarea using \n for new line, but html page using br tag.
There is my code:
$('#id_textarea').val(cell_string.replace(/<br>\*/gi,'\n'));
I know, that string has br tag likes (NOTE-1):
<br></br>
I tried:
$('#id_textarea').val(cell_string.replace(/**<br></br>**\*/gi,'\n'));
But still cannot understand, how the regular expression works.
And there is picture of my issue.
NOTE-1 - these br tags are make by:
content = content.replace(/\n/g, "<br>");
IN DB there is:
<br>
In Firefox:
<br></br>
In Chrome:
<br>
Why?
Your regex is not right, try:
$('#id_textarea').val(cell_string.replace(/<br *\/?>/gi, '\n'));
THE DEMO.
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