JSFiddle - React, Tailwind, and code Playground
HTML
<div class="thing1" onclick="change_the_after_attribute(this)">I am a thing. Click me.</div>
CSS
.thing1 {
background-color:#ffcc88;
display: inline-block;
}
.thing1::after {
content:"I am what comes ::after a thing :)";
display: inline-block;
background-color: #4455ff;
padding:3px;
border: 1px solid #000000;
}
.thing1.extra_stuff::after {
content:"Some parts of me, changed!";
background-color: #8888cc;
}
JavaScript
function change_the_after_attribute(thing_button) {
thing_button.className="thing1 extra_stuff";
}