I also tested the script with (n + 5) instead of (-n + 5). This is showing 5 items, but the inner html content gets also display: none.
Is there anything else I´m doing wrong?
when you look into MDN docs :nth-child() - CSS: Cascading Style Sheets | MDN you will see in their example adding :nth-child() to li selector and formula is applied on all siblings of an identical element type. More in MDN docs.