JSFiddle - React, Tailwind, and code Playground
HTML
<div id="EULA_content">
This is a legal agreement ("Agreement") between you and ...
License
Subject to you continued and ongoing compliance with the terms and conditions set ...
Restrictions
Except as otherwise explicitly provided in this Agreement, ...
Ownership
Except for this license granted to you, as between you and ...
Disclaimer of Warranties
Use at your own risk. ...
</div>
JavaScript
function nl2br (str, is_xhtml) {
var breakTag = (is_xhtml || typeof is_xhtml === 'undefined') ? '<br />' : '<br>';
//console.log(breakTag);
return (str + '').replace(/([^>\r\n]?)(\r\n|\n\r|\r|\n)/g, '$1'+ breakTag+ breakTag +'$2');
}
var originalText=document.getElementById('EULA_content').innerHTML;
var newText=nl2br(originalText,true);
document.getElementById('EULA_content').innerHTML=newText;