How to add a CSS class to some element?

Hello! I want to execute a js script that should change classes. Can I add a class to some elements? My task is to implement the top panel, as in this example:

Hey, you can use the built-in scroll event to do such things. I provided you an example, hope that’s what you’re looking for. (115.6 KB)

Thank you for help )