JSFiddle - React, Tailwind, and code Playground

HTML

<script>
            function returnList(x)
            {
                return document.getElementsByTagName(x);
            }


    function writeList(list) {
        var i, result = "";
        for (i = 0; i < list.length; i++) {
            if (i > 0) {
               result += "<br />";
            }
            result += list[i].innerHTML;
        }
        document.getElementById("myContainer").innerHTML = result;
    }

            function doAll(x) 
            {
                writeList(returnList(x));
            }
        </script>

        <p>XXX</p>
        <p>YYY</p>
        <div style = 'background-color: gray;'>
            <p>YYY</p>
            <p>XXX</p>
        </div>

        <button type = 'button' onclick = "doAll('p')">
            Click me!
        </button>

<div id="myContainer"></div>