The issue is really about how jQuery works - it essentially makes changes to the DOM. As SAPUI5 controls are rerendered they can be removed from the DOM and then replaced or even completely rebuilt. So if you have made changes to the DOM you will need to redo them.
A good place for this is in the controller method onAfterRendering.
But, for your example of changing CSS styles you should probably use the SAPUI5 control method addStyleClass method.
Cheers
Graham Robbo