Remove all the child views of a element

Hi, I am trying to remove all the child views of a particular element by getting all it’s child views and looping over them and removing them one by one, but I don’t know why the loops stops after after removing the first element. Sample Code: Code Snippet

When you try to modify something in forEach loop, it can lead to some mistakes. There’s a better way to remove all child views - Rebuilding Application Layout.
In this case you can replace your layout with an empty one:

function rebuildLayout(){
    }, $$('triggerSection'));

Please, check an example: Code Snippet