Visible only when I click button

I have a Collection A displayed on my site. When I click on an item in Collection A which will be a div, I want to show a div with data from Collection B. Collection B has a reference field to Collection A, so I need to display only the related data.