JSFiddle - React, Tailwind, and code Playground

HTML

<input type="text" id="text" />
<input type="submit" id="add" value="add" />
<div id="list"></div>

CSS

body {
  font-family:arial;
}
#list {
  border:1px solid #333;
  width:300px;
}
#list h1 {
  position:relative;
  border:1px solid #333;
  max-width:300px;
  min-width:300px;
}
#list p {
  color:red;
  position:absolute;
  right:0;
  top:-35px;
}

JavaScript

$(function() {
$('#text').val('');

$('#text').bind("change keyup input",function() { 
    var keyed = $(this).val();
  });

//click and add
$("#add").click(function() {
var val=$("#text").val();
$("#text").val('');
var item ="<h1>"+val+'<p class="del">x</p>'+"</h1>";

$("#list").append(item);
});

$('#list').each(function() {
  if ($("#list").text() == "") {
     $(this).css("border","none");
    }else {
    $(this).css('border', '3px solid black'); 
    }
});

$('body').on('click', '.del', function() {
$(this).parent().remove();
});

});//function ends