JSFiddle - React, Tailwind, and code Playground

by ricardolohmann

HTML

<div id="replace">
    text<div> text </div><div> text </div><div> text </div>
</div>

JavaScript

$('#replace').html(function(i, html) {
    return html.replace(/<(|\/)div>/g, function(match) {
        return match == '<div>' ? '<br>' : '';
    });
});


console.log($('#replace').html());