JSFiddle - React, Tailwind, and code Playground

by Michael Danilov

HTML

<button><div></div></button>

CSS

button {
    width: 100px;
    height: 100px;
}

button div {
    background-color: red;
    width: 50px;
    height: 50px;
    margin: 12.5px;
}

JavaScript

var fn = function() {
    var button = document.getElementsByTagName('button');
    button = button[0];

    button.addEventListener('click', function(event){
        console.log(event);
        console.log(event.target);
    });
};

if (document.readyState != 'loading'){
	fn();
} else {
	document.addEventListener('DOMContentLoaded', fn);
}