<div id='lorem'>
<div id='ipsum'>
<div></div>
<div></div>
<div id='fox'></div>
<div></div>
</div>
<div id='menu'>
<div id='item-1'></div>
<div></div>
<div></div>
<div id='controls'></div>
</div>
</div>
<div id='output'></div>
<script>
'use strict';
var items = document.querySelectorAll('[id]');
var output = document.getElementById('output');
var links = Array.from(items).forEach(item => {
output.innerHTML +=`<a href="#${ item.id }">#${ item.id }</a> `;
});
</script>