JSFiddle - React, Tailwind, and code Playground
HTML
<input type="text" />
<div class="div">
</div>
CSS
.div{
height:800px;
width:100%;
background: red;
}
JavaScript
$('input').focus(function () {
$(this).attr('class', 'hastext', function(){
$('.div').css({
'backround': 'blue',
})
});
});
$('input').blur(function () {
if($(this).val() == '') {
$(this).removeAttr('class');
}
});