Change background in gallery module

Can someone help?
I want to change the background image of the page (by ID/Class of the element) dynamically by a click on the filterable tabs/category in the gallery modul. I think, I would have different css-files and a snippet for the logic in the functions.php?