Get a list of the Element’s descendants (children and children’s children), optionally filtered by a callback function.
.getSiblings(callback = undefined)true, if an item should be added (optional ).A simple example could look like this:
document.getElementById('foo') .getDescendants() .forEach( (item) => { … });
By using a filtering function, e.g. to only collect descendants which are <a> elements:
let list = document.getElementById('foo') .getDescendants( e => e.nodeName == 'A' );
.nodeName property always contains the element name in uppercase letters!