Dynamically set block Id

I have a scenario where I want to list a bunch of dynamic content via query block and then add a dynamic list via another query block where when clicking on an item the browser scrolls to another item in the other query block via fragments ([https://my-url.com**#my-fragment**).