JSFiddle - React, Tailwind, and code Playground

by thecodeparadox

HTML

<div>Div</div>
<input type="text" />

CSS

body { margin: 30px; }

JavaScript

$('input').on("keyup", function() {
    
    var val = $(this).attr('value'),
        previous = $(this).prev();
    
    if ( val === '' ) {
        previous.show();
        console.log('Empty');
    }
    else if ( val !== '' ) {
        previous.hide();
        console.log('Text');
    }
    
});