JSFiddle - React, Tailwind, and code Playground

by Luke

HTML

<ul id="selecteds">
</ul>
<ul id="list">
    <li>asdf</li>
    <li>qwer</li>
    <li>zxcv</li>
</ul>

JavaScript

$( "ul#list li" ).on( "click", function(event){
    var t = $(event.target).text();
    alert(t);
    alert($("ul#selecteds li").length);
    if( $("ul#selecteds li").length == 0 ) {
        $("ul#selecteds").append("<li></li>");
    }

    $( "ul#selecteds li" ).each( function(index){
        var s = $( this ).text();
        alert(s);
        alert($(event.target).clone() );
        if ( s == t ){
            /*
            alert("he");
            $(event.target).clone().appendTo($("ul#selecteds"));
            alert($(event.target).clone() );
            */
            
        }
    });
});

/*
$( "li" ).each(function(i, el){
    alert(i + ":" + el);
    });
    */
/*
if ( $("ul#selecteds li").length = 0 ){
    alert("t");
}*/
/*
alert($("ul#selecteds li").length);
*/