JSFiddle - React, Tailwind, and code Playground

by PM5544

CSS

div{
     padding:10px;
     border: 1px dashed #000;  
}

JavaScript

var fragment = document.createDocumentFragment()
,   div = document.createElement( 'div' )
;
div.id = "myId";
fragment.appendChild( div );


document.body.appendChild( fragment.cloneNode( true ) );

document.getElementById( 'myId' ).innerHTML = 'the right one is selected';

// this will yield undesirable results but for explanatory reasons we include it again with the same id...

document.body.appendChild( fragment.cloneNode( true ) );