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

html - Cut text on left side inside button while centering -

plugins - CodeIgniter support on netbeans 8.0 -

php - Selecting items from MySQL for a status update feed efficiently while accounting for possible spam -