CSS not working properly for Dynamic Font

I’m using the provided code to dynamically change the font based on a dropdown selection. However, it works inconsistently - sometimes it functions correctly, and other times it doesn’t. I’m stuck and could really use your help. Could you point out any potential mistakes in my code or suggest alternative solutions?