In the script I'm working on, I'm appending markup for a feedback form to the body and then centering that element (a DIV) on screen with jQuery. In the code sample below, form_code holds my form markup. The defined CSS styles for #feedback_form explicitly define a width. However, the calculation for width() called immediately after appending is calculating wrong, returning a dimension almost equal to the entire width of the page.
If I alert the width with console, even seconds later, it calculates correctly. Never run into this before, can somebody shed some light on this?
jQuery('body').append(form_code);
alert(jQuery("#feedback_form").css("width"));