I am using querySelector to fetch div in order to scroll on that position.
const anchor = document.querySelector('#' + i)
if (anchor) {
anchor.scrollIntoView(true);
window.scrollBy(0, -190);
}
The problem is that in some divs I have id with space e.g Vegan Pizza (variable i) and in this case variable anchor is null and scrolling is not working.
Anyone has idea how to make querySelector working with id with spaces?