JSFiddle - React, Tailwind, and code Playground

HTML

<div id="toParse">

<div style="text-align: right;">text1</div>
<div style="text-align: right;">text2</div>
<div style="text-align: right;">text3</div>
<div style="text-align: right;">text4</div> 
    
</div>

JavaScript

$('body').ready(function() {
    
    var template = $('#toParse div').first().clone();
    
    var result = "";
    $('#toParse div').each(function(index, element) {
        result += $(element).html();
        result += "<br/>";
    });
    
    // you can add some extra code here to remove that 
    // extra final <br/>
    
    $('#toParse').html($(template).html(result));
    console.log(result); 
});