JSFiddle - React, Tailwind, and code Playground

HTML

<label id='input1Label'>Label</label>
<input id='input1'>

CSS

#input1Label {
  visibility: hidden;
}

JavaScript

$('input').on('change paste keydown', function(event) {
    var inputID = event.target.id;
    var value = $('#' + inputID).val();
    $('#' + inputID + 'Label').css('visibility', 'visible');   

    if (value == ''){
        $('#' + inputID + 'Label').css('visibility', 'hidden');
    }
})