JSFiddle - React, Tailwind, and code Playground

by the wazz

HTML

<div id="div1">
    <p id="p1">This is a paragraph.</p>
    <p id="p2">This is another paragraph.</p>
</div>

<script>
    function saveSelection(selection) {
        var para = document.createElement("p3");
        var node = document.createTextNode(selection);
        para.appendChild(node);
        var element = document.getElementById("div1");
        element.appendChild(para);
    }
</script>

<button type="button" onclick="saveSelection('hello')">New</button>