JSFiddle - React, Tailwind, and code Playground

HTML

<input class="test" type="text" value="">

CSS

.removeMe {
	color:red;
}
.addMe {
	color: #0f0;
}

JavaScript

$(function () {
    function isEmpty() {
        if (!$(".test").val()) {
        alert("Empty");
            $(this).addClass("removeMe");
        } else {
        alert("not Empty");
            $(this).addClass("addMe");
        }
    }
    isEmpty();
});