JSFiddle - React, Tailwind, and code Playground

by JamesWolf

HTML

<li class="test">a1</li>
<li class="test">a2</li>
<li class="test">a3</li>
<li class="test">a4</li>

JavaScript

$(function a() {
    $(".test").on("click", function () {
        var _sender = $(this);
        b(_sender).bind(a());
    });
});

function b(_sender) {
    var old = '<li class="test">' + $(_sender).html() + '</li>';
  
    if($(_sender).next(".test").html() != null ){
        alert($(_sender).next(".test").html());
         $(_sender).next().after(old).fadeIn();
         $(_sender).remove();
    }
};