JSFiddle - React, Tailwind, and code Playground

HTML

<ul></ul>
<button id="1">add</button>
<button id="2">remove</button>

CSS

ul:empty{
    display:none;
}
ul{
    width:100px;
    height:100px;
    background:red;
    display:block;
}

JavaScript

$(document).ready(function() {
    $('button#1').on('click', function() {
        $('ul').append('<li>hi</li>');
    });
    
    
    $('button#2').on('click', function() {
        $('ul li:last-child').remove();
    });
});