jquery - html textarea replace br tag to \n -


i need edit row's cell in table using new lines characters. editation of these cells make textarea jquery. problem is, textarea using \n new line, html page using br tag.

there code:

$('#id_textarea').val(cell_string.replace(/<br>\*/gi,'\n')); 

i know, 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 regular expression works.

and there picture of issue.

note-1 - these br tags make by:

content = content.replace(/\n/g, "<br>"); 

in db there is:

<br> 

in firefox:

<br></br> 

in chrome:

<br> 

why?

your regex not right, try:

$('#id_textarea').val(cell_string.replace(/<br *\/?>/gi, '\n')); 

the demo.


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -

javascript - Ajax jqXHR.status==0 fix error -