This is very basic JavaScript. Check this thread: https://intellipaat.com/community/21064/how-to-change-an-elements-class-with-javascript
I don’t have experience with triggering css changes through a JS action, but what I often do is utilize the dynamic class functionality in your property section.
This way you can:
See the set-up below
.parentclass{
   .childclass1{
       background-color: //color;
       color: //color;
       }
   .childclass2{
      background-color: //color;
      color: //color;
      }
}