JSFiddle - React, Tailwind, and code Playground

HTML

<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.0.0/jquery.min.js"></script>
<body>
    <div id="main">
        <button type="button" id="demo">Click</button>
    </div>
</body>

JavaScript

$(document).ready(function(){
    $("#demo").on("click", function(){
        $("#main").after(
        "<textarea></textarea><div class='text-count-area'>Word count: 0 </div>");

        // Bind the text area to the keyup event
        $("textarea").on('keyup', function(val) {
        var words = this.value.match(/\S+/g).length;
        // write the word count to the immediate div afterwards
        $(this).next(".text-count-area").text("Word count: " + words);
        });
    });
});