title: Javascript get li values and encode them
body: <p>At the moment I have two (maybe more) unordered lists which are sortable with jquery and ui.</p>
  
  <p>The things that work are that the lists are connected, items are draggable, items can be removed and a form that adds to the list.</p>
  
  <p>What I need however is a function that gets all the content for li items and json encode them ready to be sent off to some db function, or something.</p>
  
  <p>Im new to jquery however and cant find documentation for li items.</p>
  
  <p>Hope Ive explained this well.</p>
  
  <p>Daniel</p>
  
  <p>UPDATE - Sample Code</p>
  
  <pre><code>    &lt;script type="text/javascript"&gt;
  
      function addSortable(value) {
          $("#sortable1").prepend("&lt;li class='ui-state-default' id='"+value+"'&gt;&lt;span class='ui-icon ui-icon-arrowthick-2-n-s'&gt;&lt;/span&gt;"+value+"&lt;/li&gt;");
      }
  
      function deleteItem(value) {
          $("#item-"+value).fadeOut('slow');
  
          $('#sortable1 li').each(function() {
              var text = $(this).text();
          });
  
          document.getElementById('jsoningreds').innerHTML = text;
  
      }
  
      $(function() {
          $("#sortable1, #sortable2").sortable({
              connectWith: '.connectedSortable'
          }).disableSelection();
      });
      &lt;/script&gt;
  
      &lt;ul id="sortable1" class="connectedSortable"&gt;
  
      &lt;li id="item-0" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;8 large chicken thighs, skinned &lt;a href="javascript:deleteItem(0)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
  
      &lt;li id="item-1" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;seasoned flour (celery salt, cayenne pepper, paprika and white pepper) &lt;a href="javascript:deleteItem(1)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li id="item-2" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;2 small eggs, beaten &lt;a href="javascript:deleteItem(2)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li id="item-3" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;100g butter &lt;a href="javascript:deleteItem(3)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  
      &lt;hr /&gt;
  
      &lt;h3&gt;Recipe number 2&lt;/h3&gt;
      &lt;ul id="sortable2" class="connectedSortable"&gt;
  
  &lt;li id="item-5" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;3 tsp vegetable oil &lt;a href="javascript:deleteItem(5)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li id="item-6" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;1 bay leaf &lt;a href="javascript:deleteItem(6)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;li id="item-7" class="ui-state-default"&gt;&lt;span class="ui-icon ui-icon-arrowthick-2-n-s"&gt;&lt;/span&gt;250g onions, finely sliced &lt;a href="javascript:deleteItem(7)" class="deleteItem"&gt;&lt;/a&gt;&lt;/li&gt;
      &lt;/ul&gt;
  
     &lt;p id="jsoningreds"&gt;hello&lt;/p&gt;    
  </code></pre>