jquery - Javascript: Get body html in one row string. How to remove linebreaks? -


i have html

<span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 10pt;">one two:</span> 

i need receive html in 1 row string.

a = $("body").clone().find("script").remove().end().html(); = a.replace("\r\n", "zzz"); = a.replace("\n", "zzz"); console.log(a); 

but it's not working. same.

<span style="font-family: tahoma, arial, helvetica, sans-serif; font-size: 10pt;">one two:</span> 

replace new line characters regex , global flag:

a.replace(/\r?\n/g, ' '); 

demo


Comments

Popular posts from this blog

javascript - Unusual behaviour when drawing lots of images onto a large canvas -

how can i manage url using .htaccess in php? -

javascript - Chart.js - setting tooltip z-index -