JSFiddle - React, Tailwind, and code Playground

HTML

<div id="test">test</div>
<div id="G"></div>

CSS

.menu {
    background-color : blue;
}

JavaScript

function menu_load(type){

    document.getElementById(type).onclick = function(){ menu_unload(type); }

    var width = 100;
    var height = 100;
    var d = document.createElement('div');
        d.id = 'menu';
        d.className = 'menu';
        d.style.width = width + 'px';
        d.style.height = height + 'px';
    document.getElementById('G').appendChild(d);

}

function menu_unload(type){
    var div = document.getElementById("menu");
    div.parentNode.removeChild(div); // doesn't remove the div
    document.getElementById(type).onclick = function() {menu_load(type);};
}

window.onload = function(){
menu_load('test');
}