title: How can I display value of a div with a button click?
body: <p>I am currently working with a wmd editor and jQuery-UI tabs. I have created an ajax/js function that will submit (when next button is clicked) the <code>wmd-preview</code> value and then php echo the result in tab 2. The problem is that I am not getting any results displayed. I am not looking for the <code>textarea</code> value but the div <code>#wmd-preview</code> value. How can I display the value of the div <code>wmd-preview</code> through my ajax/function?</p>
  
  <p><strong>JS</strong></p>
  
  <pre><code>&lt;script&gt;
  $(function () {
      var $tabs = $('#tabs').tabs({
          disabled: [0, 1],
          select: function () {
              $.ajax({
                  type: "POST",
                  url: "post_tabs.php",
                  data: {
                      "wmd": $("#wmd-preview").val(),
                  },
                  success: function (result) {
                      $("#tab-2").html(result);
                  }
              });
          }
      });
  
      $(".ui-tabs-panel").each(function (i) {
          var totalSize = $(".ui-tabs-panel").size() - 1;
          if (i != totalSize) {
              next = i + 2;
              $(this).append("&lt;a href='#' class='next-tab mover' rel='" + next + "'&gt;Next Page &amp;#187;&lt;/a&gt;");
          }
          if (i != 0) {
              prev = i;
              $(this).append("&lt;a href='#' class='prev-tab mover' rel='" + prev + "'&gt;&amp;#171; Prev Page&lt;/a&gt;");
          }
      });
  
      $('.next-tab').click(function () {
          var currentTab = $('#tabs').tabs('option', 'selected');
          if (
          (
          currentTab == 0 &amp;&amp; /*(B)*/
          $.trim($('#wmd-input').val()).length &gt; 0
          )
          ) {
              var tabIndex = $(this).attr("rel");
              $tabs.tabs('enable', tabIndex).tabs('select', tabIndex).tabs("option", "disabled", [0, 1]);
          } else {
              switch (currentTab) {
              case 0:
                  alert('Please fill out all the required fields.', 'Alert Dialog');
                  break;
              }
          }
          console.log("preventing default");
          return false;
      });
  
      $('.prev-tab').click(function () {
          var tabIndex = $(this).attr("rel");
          $tabs.tabs('enable', tabIndex).tabs('select', tabIndex).tabs("option", "disabled", [0, 1]);
          return false;
      });
  
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>PHP</strong></p>
  
  <pre><code>&lt;?
  if (isset($_POST['wmd'])){
      $wmd = $_POST['wmd']; 
      echo ('&lt;div id="text_result"&gt;&lt;span class="resultval"&gt;&lt;h2&gt;Textarea Echo result:&lt;/h2&gt;'.$wmd.'&lt;/span&gt;&lt;/div&gt;');
                         }
  ?&gt;
  </code></pre>
  
  <p><strong>HTML</strong></p>
  
  <pre><code>&lt;div id="tab-1" class="ui-tabs-panel ui-tabs-hide"&gt;
      &lt;div id="wmd-button-bar"&gt;&lt;/div&gt;
      &lt;textarea id="wmd-input" name="wmd-input" cols="92" rows="15" tabindex="6"&gt;&lt;/textarea&gt;
      &lt;div id="wmd-preview"&gt;&lt;/div&gt;
  &lt;/div&gt;
  
  &lt;div id="tab-2" class="ui-tabs-panel ui-tabs-hide"&gt;
  
  &lt;/div&gt;
  </code></pre>