JSFiddle - React, Tailwind, and code Playground

by Brian Scaturro

HTML

<button id="mybutton">Click Me</button>
<input id="mytext" type="text" />

JavaScript

var btn = document.getElementById('mybutton');
var eventType = 'click';
var onClick = function() {
    alert('hello world');
};

btn.addEventListener(eventType, onClick);


var txt = document.getElementById('mytext');
txt.addEventListener('blur', function() {
    if (this.value != 'hello') {
        this.style.border = '10px solid red';
        this.value += ' (it was rude to not say hello)';
    } else {
        this.style.border = '10px solid green';
    }
});