JSFiddle - React, Tailwind, and code Playground
by MuLtDirectX
HTML
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
</head>
<body>
</body>
</html>
CSS
.block {
width:100px;
height:100px;
background: blue;
}
JavaScript
function createBlock(){
const block = document.createElement('div')
block.className = 'block'
document.querySelector('body').appendChild(app)
return function(){
setTimeout(()=>{
block.remove()
console.log('Block has been removed')}, 2000)
}
}
var myFunc = createBlock()
myFunc()