JSFiddle - React, Tailwind, and code Playground

by Prasad Gavande

HTML

<!------------------------------------------------- move element with changin div id complete solution -------------------------------------------------->
<div id="panel1">
    <input type="button" value="add" id="btn1" />
    <br>
    <input type="button" value="add" id="btn2" />
    <br>
    <input type="button" value="add" id="btn3" />
</div>
<div id="panel2" style="background-color:gray"></div>

JavaScript

var flag = 0;
    $("input").click(function () {
        if (flag === 0) {
            $(this).appendTo("#panel2");
            $(this).val("remove");
            flag = 1;
        } else {

            $(this).appendTo("#panel1");
            $(this).val("add");
            flag = 0;

        }

    });