<div class="sidebar-submenu active" style="display: block;max-height: 220px; overflow: scroll;">
    <ul>
        <li class="list-unstyled">
            <a class="categoryItem">Food</a>
            <ul>
                <li class="list-unstyled">
                    <a class="categoryItem">Hús_hentesáru</a>
                    <ul>
                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="32">Csirke, tyúk</a>
                        </li>

                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="33">Felvágott, töltelékes áru</a>
                        </li>

                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="34">Kacsa, liba</a>
                        </li>

                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="35">Marha, borjú, bárány</a>
                        </li>

                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="36">Pulyka</a>
                        </li>

                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="37">Sertés</a>
                        </li>

                        <li class="list-unstyled">
                            <a class="categoryItem clickable" data-id="38">Vadhús</a>
                        </li>

                    </ul>
                </li>

                <li class="list-unstyled">
                    <a class="categoryItem clickable" data-id="41">Olaj_zsiradék</a>
                </li>

                <li class="list-unstyled">
                    <a class="categoryItem clickable" data-id="51">Továbbfeldolgozott_félkész_termék</a>
                </li>

            </ul>
        </li>



    </ul>
</div>
<script src="https://code.jquery.com/jquery-3.6.0.slim.min.js" integrity="sha256-u7e5khyithlIdTpu22PHhENmPcRdFiHRjhAuHcs05RI=" crossorigin="anonymous"></script>

<script>
    $( document ).ready(function() {
        console.log( "ready!" );
        $('.clickable').on('click',function (){

/*        let res=$(this).parents('li')
                .filter(function(){return $(this).children('a.categoryItem').length;})
                .map(function(){return $(this).text();})
                .toArray().reverse().join('/');
*/
            //let items=[];
            let res='';
            let items=$(this).parents('li').toArray();
            items.shift();
            items.reverse();
            for (const item in items) {
                res+=$(items[item]).children('a.categoryItem').text()+'/'
            }
            res+=$(this).text();
            console.log(res);
        });

    });

</script>
