title: Styling appended elements
body: <p>I'm building some of a webpage using <code>.append()</code> to add elements to another generated parent element. I want to style the added elements, but none of the styles given to them using <code>.css()</code> are applied, possibly due to the fact these elements haven't been added to the page yet?</p>
  
  <p>Here's my code:</p>
  
  <pre><code>var stickyHeader = $("&lt;div&gt;&lt;/div&gt;");
  
  $(".stickyHeader").find("th").each(function() {
      var offset = $(this).offset().left;
      var objWidth = $(this).width();
  
      stickyHeader.append("&lt;span&gt;" + $(this).html() + "&lt;/span&gt;").css({width: objWidth, top: 0, left: offset, position: 'fixed'});
  });
  
  $("body").append("&lt;div class=\"stickyHeader\"&gt;" + stickyHeader.html() + "&lt;/div&gt;");
  </code></pre>
  
  <p>Do I need another <code>.each()</code> to loop through the <code>span</code>s once theyre added to <code>body</code>, or is there a nicer, cleaner solution?</p>
  
  <p>I forgot to mention that each <code>span</code> is given a width from another element on the page, so this can't be done solely with CSS and classes.</p>