Have you tried

    $('#cboxWrapper', context).css('backgroundColor', bg);

It makes sure your css is ran with the new markup
Or checked that your selector actually works ?

    console.log($('#cboxWrapper')); // Then check your console