JSFiddle - React, Tailwind, and code Playground

HTML

<div id="foo">One<br/>two</div>

JavaScript

$('br').replaceWith("\n");

alert($('#foo').text());