JSFiddle - React, Tailwind, and code Playground

HTML

<input type="button" id="click_me" value="Click Me"/>
<div id="container"> Hi dude</div>

JavaScript

$(function() {
     var count = 0;
    $('#click_me').click(function(){
        var container = $('#container').css('display');
         count += 1;
        
        var id = $('#id').html();
        if (count == 1) {
                $.ajax({
                type: 'POST',
                data: {id: id},
                url: "ajax/get_items.php",
                }).done(function(data) {
                $('#container').html(data);
                }).success(function(){
                $('#container').show('fast');
                });
                }
        if (count == 2) {
        $('#container').hide('fast');
        
        }
        if (count == 3) {
        // call your function again or what ever you want to do
         
        }
        });
});