JSFiddle - React, Tailwind, and code Playground

by Dineshkani

HTML

<div id="firstdiv" class="sample">
    <div name="jQuery"> Hello Jquery </div>
</div>
<input type="button" value="clone" />

CSS

.sample{
    width: 250px;
    color: blue;
    text-align: center;
}

JavaScript

$("input").click(function(){
    $("#firstdiv").children('div:eq(0)').clone().appendTo("#firstdiv");
    $("#firstdiv").children('div').eq(0).clone().appendTo("#firstdiv");
});

//In here both eq are the same selectors which selects the 0th index element in the given Selector. 

//Eg. It search for the firstdiv id and then go the all childrens div and selects the 0th element div and append it to the firstdiv id element.