Przejdź do JavaScript NextElementsbling
<div id="div-01">Here is div-01</div>
<div id="div-02">Here is div-02</div>
<script type="text/javascript">
let el = document.getElementById('div-01').nextElementSibling;
console.log('Siblings of div-01:');
while (el) {
console.log(el.nodeName);
el = el.nextElementSibling;
}
</script>
ayaan