I am using this progress bar :
http://twitter.github.com/bootstrap/components.html#progress
And would like to give it a custom color, known only at runtime (
Your code is actually working, just that the progress bar is actually using a gradient as a color instead of a solid background-color property. In order to change the background color, set the background-image to none and your color will be picked up:
$('#pb').css({
'background-image': 'none',
'background-color': 'red'
});