title: append() to dynamically created tab
body: <p>I am creating an editor application which requires dynamically appending HTML into the document. I am using JQuery UI tabs to divide the document into sections. I want to be able to dynamically add tabs and then use append() to add content into the tabs.</p>
  
  <p>The page has 3 tabs when it loads and I want to be able to dynamically add more when required.</p>
  
  <p>Currently my code works when appending content into the 3 non-dynamic tabs, and when creating a new tab. For some reason I cannot append any content into a new, dynamically created tab.</p>
  
  <p>Why won't my code work for adding content to a dynamically created tab?</p>
  
  <pre><code>$(function () {
      $('#addTab').click(function () {
          var num_tabs = $('div#tabs ul li.tab').length + 1;
          $('div#tabs ul').append(
              '&lt;li class="tab"&gt;&lt;a href="#tab' + num_tabs + '"&gt;Section ' + num_tabs + '&lt;/a&gt;&lt;/li&gt;');
          $('div#tabs').append(
              '&lt;div id="tab-' + num_tabs + '&gt;&lt;/div&gt;');
          $('#tabs').tabs("refresh");
          $('#tabs').tabs("option", "active", -1); //makes the new tab active
      });
  });
  
  //Insert content into the currently selected tab
  function insertContent(content) {
      var activeTab = $("#tabs").tabs('option', 'active');
      activeTab += 1;
      console.log(activeTab);
      $("#tab-" + activeTab).append(content);
  }
  </code></pre>
  
  <p>HTML after creating a 4th tab:</p>
  
  <pre><code>&lt;div id="tabs" class="ui-tabs ui-widget ui-widget-content ui-corner-all"&gt;
    &lt;ul class="ui-tabs-nav ui-helper-reset ui-helper-clearfix ui-widget-header ui-corner-all" role="tablist"&gt;
   &lt;li class="tab ui-state-default ui-corner-top" role="tab" tabindex="0" aria-controls="tab-1" aria-labelledby="ui-id-1" aria-selected="false"&gt;&lt;a href="#tab-1" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-1"&gt;Section 1&lt;/a&gt;&lt;/li&gt;
   &lt;li class="tab ui-state-default ui-corner-top" role="tab" tabindex="-1" aria-controls="tab-2" aria-labelledby="ui-id-2" aria-selected="false"&gt;&lt;a href="#tab-2" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-2"&gt;Section 2&lt;/a&gt;&lt;/li&gt;
   &lt;li class="tab ui-state-default ui-corner-top" role="tab" tabindex="0" aria-controls="tab-3" aria-labelledby="ui-id-3" aria-selected="false"&gt;&lt;a href="#tab-3" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-3"&gt;Section 3&lt;/a&gt;&lt;/li&gt;
   &lt;li class="tab ui-state-default ui-corner-top ui-tabs-active ui-state-active" role="tab" tabindex="0" aria-controls="tab4" aria-labelledby="ui-id-7" aria-selected="true"&gt;&lt;a href="#tab4" class="ui-tabs-anchor" role="presentation" tabindex="-1" id="ui-id-7"&gt;Section 4&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;
  
   &lt;div id="tab-1" aria-labelledby="ui-id-1" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="false" aria-hidden="true" style="display: none;"&gt;Section Title:&lt;input class="sectionTitle"&gt;&lt;br&gt;&lt;p contenteditable="true" class="cke_editable cke_editable_inline cke_contents_ltr cke_show_borders" tabindex="0" spellcheck="false" role="textbox" aria-label="Rich Text Editor, editor1" title="Rich Text Editor, editor1" aria-describedby="cke_83" style="position: relative;"&gt;Paragraph text&lt;/p&gt;&lt;/div&gt;
  
  &lt;div id="tab-2" aria-labelledby="ui-id-2" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="false" aria-hidden="true" style="display:none;"&gt;Section Title:&lt;input class="sectionTitle"&gt;&lt;p contenteditable="false" class="cke_editable cke_editable_inline cke_contents_ltr cke_show_borders" tabindex="0" spellcheck="false" role="textbox" aria-label="Rich Text Editor, editor2" title="Rich Text Editor, editor2" aria-describedby="cke_153" style="position: relative;"&gt;Paragraph text&lt;/p&gt;&lt;/div&gt;
  
  &lt;div id="tab-3" aria-labelledby="ui-id-3" class="ui-tabs-panel ui-widget-content ui-corner-bottom" role="tabpanel" aria-expanded="false" aria-hidden="true" style="display: none;"&gt;Section Title:&lt;input class="sectionTitle"&gt;&lt;p contenteditable="false" class="cke_editable cke_editable_inline cke_contents_ltr cke_show_borders" tabindex="0" spellcheck="false" role="textbox" aria-label="Rich Text Editor, editor3" title="Rich Text Editor, editor3" aria-describedby="cke_223" style="position: relative;"&gt;Paragraph text&lt;/p&gt;&lt;/div&gt;
  &lt;/div&gt;
  </code></pre>