Home

DOM.

Remove/add elements to element

empty
filled
empty again
// fill let filled = document.getElementById( 'filled' ); for( var i = 0; i < 10; i++ ) { let span = document.createElement( 'span' ); span.setAttribute( 'class', 'greenBorder' ); span.innerHTML = 'C' + i; filled.appendChild( span ); } // clear while( filled.firstChild ) { filled.removeChild( filled.firstChild ); }