title: How to delete a specific sessionStorage value and decrement another sessionStorage value at the same time
body: <p>I was wondering how can I delete a specific sessionStorage value from the key <code>worker</code> as well as decrement the key <code>limit</code> value by 1 without affecting the other sessionStorage values every time a specific key worker is deleted?</p>
  
  <p>Here is my Jsfiddle <a href="https://jsfiddle.net/d7e92k5d/2/" rel="nofollow">https://jsfiddle.net/d7e92k5d/2/</a></p>
  
  <p>HTML </p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;
          &lt;div class="worker-container-last"&gt;
              &lt;label class="worker-label"&gt;&lt;input type="text" class="first-name" /&gt;&lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="worker-container-last"&gt;
              &lt;label class="worker-label"&gt;&lt;input type="text" class="last-name" /&gt;&lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="worker-container-last"&gt;
              &lt;label class="worker-label"&gt;
                  &lt;select name="title[]" class="title"&gt;
                      &lt;option value="Select a Title" selected="selected"&gt;Select a Title&lt;/option&gt;
                      &lt;option value="Boss"&gt;Boss&lt;/option&gt;
                      &lt;option value="Worker"&gt;Worker&lt;/option&gt;
                      &lt;option value="Manager"&gt;Manager&lt;/option&gt;
                  &lt;/select&gt;
              &lt;/label&gt;
          &lt;/div&gt;
          &lt;div class="add-more"&gt;&lt;/div&gt;
          &lt;div&gt;&lt;a class="worker" title="" href=""&gt;Add Another Worker&lt;/a&gt;&lt;/div&gt;
      &lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>JQuery  </p>
  
  <pre><code>var worker_record = [];
  $(document).ready(function(){
      new_worker();
      $('.worker').on('click', function(e){
          e.preventDefault();
          e.stopPropagation();
  
          if(sessionStorage.getItem("limit") === null){
              sessionStorage.setItem('limit', 0);
          }
  
          if(sessionStorage.getItem('limit') &lt;= 2){
              var first_name = $('.first-name').val();
              var last_name = $('.last-name').val();
              var title = $('.title:first').val();            
  
              var tblObj = {first_name: first_name, last_name: last_name, title: title};
              worker_record.push(tblObj);
  
              sessionStorage.worker = JSON.stringify(worker_record);
              new_worker();
  
              var count = sessionStorage.getItem('limit');
              count++;
              sessionStorage.setItem('limit', count);  
          }
      });
  
      function new_worker(){
          var max_fields = 3;
          var x = 0;
  
          if(!(typeof sessionStorage.worker === 'undefined' || sessionStorage.worker.length&lt;1)){
              worker_record = JSON.parse(sessionStorage.worker);
          }
  
          $('.add-more').empty();
          for(var i=0; i&lt;worker_record.length; i++){
              if(x &lt; max_fields){
                  x++;
                  var first_name = worker_record[i].first_name;
                  var last_name = worker_record[i].last_name;
                  var title = worker_record[i].title;
  
                  var worker = '&lt;div class="worker-container"&gt;&lt;div class="delete-worker"&gt;&lt;a title="" href="#"&gt;Delete&lt;/a&gt;&lt;/div&gt;&lt;div class="update-worker"&gt;&lt;a title="" href="#"&gt;Update&lt;/a&gt;&lt;/div&gt;&lt;div class="worker-box"&gt;&lt;label class="another-worker"&gt;&lt;input type="text" name="workers_first_name[]" class="first-name" value="' + first_name + '" /&gt;&lt;/label&gt;&lt;/div&gt;&lt;div class="worker-box"&gt;&lt;label class="another-worker"&gt;&lt;input type="text" name="workers_last_name[]" class="last-name" value="' + last_name + '" /&gt;&lt;/label&gt;&lt;/div&gt;&lt;div class="worker-box-last"&gt;&lt;label class="another-worker"&gt;&lt;select name="workers_title[]" class="title workers-title-options"&gt;&lt;option value="Select a Title" selected="selected"&gt;Select a Title&lt;/option&gt;&lt;option value="Boss"&gt;Boss&lt;/option&gt;&lt;option value="Worker"&gt;Worker&lt;/option&gt;&lt;option value="Manager"&gt;Manager&lt;/option&gt;&lt;/select&gt;&lt;/label&gt;&lt;/div&gt;&lt;/div&gt;';
  
                  $('.add-more').append(worker);
                  $('.title:eq('+$('.workers-title-options').length+')').val(title);
              }
          }
  
          $('.first-name:first').val('');
          $('.last-name:first').val('');
          $('.title:first').val('Select a Title');
      }
  
      $('.add-more').on('click', '.delete-worker', function(e){
          e.preventDefault();
          e.stopPropagation();    
  
          $(this).parent('div').remove();
          worker_record = JSON.parse(sessionStorage.worker);
          worker_record.splice(worker_record.length -1, 1);
          sessionStorage.worker = JSON.stringify(worker_record);
      });
  });
  </code></pre>