JSFiddle - React, Tailwind, and code Playground

by piyush saraf

HTML

<div><p>text <br><span>more</span> <br>text</p></div>
    
    <button onclick="totext()">to text</button>
    <button onclick="tohtml()">to html</button>

CSS

p { color: blue; }
span { color: red; }

JavaScript

function totext() {
    var d = $("div");
    d.text(d.html());
}

function tohtml() {
    var d = $("div");
    d.html(d.text());
}