Changing CSS onApplicationInit()

Have anyone tried changing css (maybe changing the background color) based on certain condition? I’m not getting any result

I have tried something like this code in onApplicationInit()

if ([variable1] == 1) {
?><script type=“text/javascript”>
$( document ).ready(function() {
$(“body”).css(“background-color: #000000”);
});
</script><?php
}

Thank you

Can you not just echo the style …It seems to work for me

echo “<style> .scFormPage { background-color: #ff0000; background-image: none; opacity: 1; filter: alpha(opacity=100); color: #000000; font-family: Lucida Grande,Tahoma,Arial,sans-serif; font-size: 12px; margin: 20px 0 20px 0; text-decoration: none } </style>”;

css is generally cached in the browser. So in order to update it you have to enforce the update in your browser see https://en.wikipedia.org/wiki/Wikipedia:Bypass_your_cache#Instructions_for_various_browsers or enforce it in your php
Maybe this will help… http://outwardfocusdesign.com/force-a-browser-to-load-a-fresh-stylesheet/