you can't change your css class via javascript. all you have to do is add different CSS and apply those to your elements conditionally. If you don't want any changes to your element style, either mark your CSS as !important or try inline styles
maybe us !important if you are giving it from css, but to be honest what gallery you have there, from where it gets the css? could you not make it custom from there?
Well, I think there is possibility, because page preloads all css files, and after it, javascript is applied, which means, that we can overrun any css property calling a proper JS code. I was thinking something like $('.gallery').css('border-color', 'red'); but for some reason, it doesn't work. @KD
$('.gallery').attr('style','border-color:black !important')for example.gallery {border-color: red}