JSFiddle - React, Tailwind, and code Playground

by janetyc

HTML

<body>
<div id="check">create a test element</div>
<span></span>
</body>

JavaScript

$("#check").click(function(){
    if(!$("#test").length){
        $("span").text("no test element");
        $(document.createElement("div")).attr("id","test").prependTo("body");
    }else{
        $("span").text("yes");
    }
});