JSFiddle - React, Tailwind, and code Playground

by Imri Paloja

HTML

<html lang="en" dir="ltr">
<head>
<style type="text/css">
.popup{
    position:absolute;
    top:0px;
    left:0px;
    margin:100px auto;
    width:200px;
    height:150px;
    font-family:verdana;
    font-size:13px;
    padding:10px;
    background-color:rgb(240,240,240);
    border:2px solid grey;
    z-index:100000000000000000;
    }
    
.cancel{
    display:relative;
    cursor:pointer;
    margin:0;
    float:right;
    height:10px;
    width:14px;
    padding:0 0 5px 0;
    background-color:red;
    text-align:center;
    font-weight:bold;
    font-size:11px;
    color:white;
    border-radius:3px;
    z-index:100000000000000000;
    }

.cancel:hover{
    background:rgb(255,50,50);
    }
    
</style>
</head>
<body>
<button id="popupButton">click here</button>
</body>
</html>

JavaScript

document.onreadystatechange = function () {
    function popUp() {
        var popup = document.createElement('div');
        popup.className = 'popup';
        popup.id = 'test';

        popup.innerHTML = "This is a test message";
        
        var cancel = document.createElement('div');
        cancel.className = 'cancel';
        cancel.onclick= function () { popup.destroy(); }
        popup.appendChild(cancel);
        
        document.body.appendChild(popup);
    }
    
    document.getElementById('popupButton').onclick = popUp;
}