JSFiddle - React, Tailwind, and code Playground
by neonDog
HTML
<div>
<button id="test" class="btn">Hello</button> <div id="test2" class="btn blue">Hello</div>
</div>
CSS
.btn {
background: red;
padding:10px;
color: white;
display: inline-block;
}
.blue {
background: blue;
}
JavaScript
const clickFn = function(){
this.innerHTML = Math.round(Math.random() * 10);
this.classList.toggle('blue');
}
class ModalManager {
constructor() {
this.modals = {
alert: 'Hey!',
password: 'this is password modal'
};
}
open(name) {
if (name in this.modals) {
alert(this.modals[name]);
} else {
alert(`""${name}" not exist in modals`);
}
}
}
const modalManager = new ModalManager();
modalManager.open('password');