JavaScript – updating value under certian conditions and append it to a June 17, 2022 June 17, 2022 / 1 minute of reading It sounds like all you need is to replace ++ and newlines with <br>: var textarea = document.getElementById('textarea'); var textareaPreview = document.querySelector('.textarea-preview'); var currentText; textarea.onkeyup = function(){ currentText = textarea.value; var previewAsString = "<p class='p-preview'>" + currentText.replace(/\+\+|\n/g, '<br>') + "</p>" textareaPreview.innerHTML = previewAsString; }; textarea { width: 300px; height: 80px; resize: vertical; } <div class="block"> <textarea id="textarea" placeholder="Type here.."></textarea> </div> <div class="block"> <div class="textarea-preview"></div> </div> CLICK HERE to find out more related problems solutions. Post navigation ← Previous PostNext Post → Leave a Comment Cancel ReplyYour email address will not be published. Required fields are marked *Type here..Name* Email* Website Save my name, email, and website in this browser for the next time I comment. Δ