Searching for "jquery css important" brought up a blog post explaining the "problem".
I'll post some additional information, but to make a long story short, here's your solution:
$('#set-bg').click(function() {
$('#box').css('cssText', 'background: blue !important');
});
The author states that:
This is not a bug but something that
most browser doesn’t acknowledge a
need since inline style already have
the highest priority other than user
defined ones. (unless you do not want
your user to change how they view your
website).
Please note that using cssText has one disadvantage and you might want to consider
using cssRules instead:
cssText will overwrites the css of
that particular element. Hence, you
will have to redeclare the rule for
that particular element all over
again.
With all that said. Please listen to the author's summary:
Using !important in CSS is not
advisable since it might kill your web
usability. Furthermore, there is no
reason why !important should be use as
inline styling already has the highest
priority. Hence, you might want to
reconsider applying !important on your
script after thinking about the
consequences that might bought to your
users.