JSFiddle - React, Tailwind, and code Playground
by ozzon91
HTML
<div> Test Test</div>
<button>button</button>
CSS
html, body {height: 100%;}
JavaScript
document.getElementsByTagName('body')[0].addEventListener('click', function(e) {
if(e.target.tagName == 'BODY') {
e.target.style.backgroundColor = getRandomColor();
}
}, true);
function getRandomColor() {
var letters = '0123456789ABCDEF'.split('');
var color = '#';
for (var i = 0; i < 6; i++ ) {
color += letters[Math.floor(Math.random() * 16)];
}
return color;
}