title: Removing items from the localStorage
body: <p>I'm trying to remove the individual items from the localStorage. I'm using localStorage for storing selected list items in the listview. I attached the checkboxes for removing the selected items from the localstorage. But when I'm removing the selected checkboxes its not deleting properly like when I selected one checkbox its deleting two or three items are deleting from the localStorage. </p>
  
  <p>Html code:</p>
  
  <pre><code>&lt;!-- Favourites page --&gt;
  &lt;div data-role="page" id="fav"&gt;
       &lt;div data-role="header" data-position="fixed"&gt;
      &lt;/div&gt;
      &lt;div data-role="content" class="ulDiv"&gt;
      &lt;ul data-role="listview" data-split-icon="minus" data-split-theme="d" data-filter="true"data-icon="false" data-filter-placeholder="Search" id="favoritesList"&gt;
              &lt;/ul&gt;
      &lt;/div&gt;
      &lt;div data-role="footer" data-position="fixed" class="my-footer"&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>My Js code:</p>
  
  <pre><code> $(document).ready( function() {
      $("#section_list").on('click', 'a', function() {
                  var item = $(this).find('h2').text();
                  var desc = $(this).find('p').text();
                  var html = '&lt;p&gt;&lt;/br&gt;&lt;p class="description"&gt;' + desc + '&lt;/p&gt;';
                  $('.addToFavoritesDiv').click(function() {
                      var url = $(location).attr('href');
                      if (!supportLocalStorage())
                      {
                          item = 'No support';
                      }
                      else
                      {
                          try
                              {
                                  localStorage.setItem('autosave' + url, item + html);
  
                              }
                          catch (e)
                              {
                                  if (e == QUOTA_EXCEEDED_ERR)
                                  {
                                      alert('Quota Exceeded');
                                  }
                              }   
                      }
                  });
      });
  
      $('#fav').click(function() {
          fromStorage();
          $("#favoritesList").listview('refresh');
      }); 
  
      $(document).on('click', '#edit', function() {
          fromGetStorage();
      });
  });
  
  function supportLocalStorage()
  {       
      return typeof(Storage) !== 'undefined';
  }
  
  function fromStorage()
  {
      $("#favoritesList").empty();
      $("#favoritesList").listview('refresh');
      for (var i = 0; i &lt; localStorage.length; i++) {
          var url = localStorage.key(i);
              var item = localStorage.getItem(url);
              $("#favoritesList").append('&lt;li id="add"&gt;&lt;a href="' + url + '" style="text-decoration:none;color:black"&gt;' + item  + '&lt;/a&gt;&lt;/li&gt;').attr('url', url);
      }
      $("#favoritesList").listview('refresh');
  }
  
  function fromGetStorage() 
      {   
       $("#favoritesList").empty();  
       $("#favoritesList").append('&lt;input type="checkbox" name="all" id="select" /&gt;Select all&lt;/br&gt;');
       $("#fav .ui-listview-filter").remove();
          for (var i = 0; i &lt; localStorage.length; i++) {
          var url = localStorage.key(i);
           var item = localStorage.getItem(url);
            $("#favoritesList").append('&lt;li id="add"&gt;&lt;div&gt;&lt;input type="checkbox" name="check" id="check"&gt;&amp;nbsp;&lt;a href="' + url + '" style="text-decoration:none;color:black"&gt;' + item + '&lt;/a&gt;&lt;/div&gt;&lt;/li&gt;').attr('url', url);
          $("#favoritesList").listview('refresh');
   }
  
  $("#select").click(function(event){
      event.stopPropagation();
  });
      $('#select').change(function() {
      if($("#select").is(':checked')) {
          $("#add #check").prop("checked", true);
          $('#empty').on('click', function() {
              localStorage.clear();
          $("#favoritesList").listview('refresh');
          });
      }
      else {
          $("#add #check").prop("checked", false);
      }
   });
  
  
  $("#add #check").click(function(event){
      event.stopPropagation();
  });
  
      $("#add #check").change(function() {
          var chkLength = $('input[name="check"]:checkbox').length;
          var chkdLength = $('input[name="check"]:checkbox:checked').length;
          if (chkLength == chkdLength)
          {
              $('#select').prop('checked', true);
          }
          else 
          {
              $('#select').prop('checked', false);
          }
  
  });
  
  $("#delete").on('click', function() {
                  var checked = $('#add #check:checkbox:checked');
                      var url = localStorage.key(checked);
                      localStorage.removeItem(url);
                      $("#favoritesList").listview('refresh');
          });
  } 
  </code></pre>