JSFiddle - React, Tailwind, and code Playground

by Minko Gechev

HTML

<div></div>

CSS

div {
    width: 30px;
    height: 30px;
    background-color: red;
}
div:after {
    content: attr(data-content);
}

JavaScript

var elem = document.querySelector('div');
elem.addEventListener('mousedown', function (e) {
    this.setAttribute('data-content', 'Text');
}, false)
elem.addEventListener('mouseup', function (e) {
    this.setAttribute('data-content', '');
}, false);