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 - Count length of each class -

What design pattern is this code in Javascript? -

hadoop - Restrict secondarynamenode to be installed and run on any other node in the cluster -