JSFiddle - React, Tailwind, and code Playground

by ydelmas

HTML

<button type="button" onclick="bonjour(this)">test</button><br>
<button type="button" onclick="bonjour(this)">test</button><br>
<button type="button" onclick="bonjour(this)">test</button><br>
<button type="button" onclick="bonjour(this)">test</button><br>
<span id="cible">jmlkjsfmlkgjsdmfg</span>

CSS

.a { background-color: green; }
.b { background-color: red; }

JavaScript

function bonjour(x) {
    // alert("bonjour tout le monde !");
    document.getElementById("cible").className="a";
    x.className = "b";
}