title: How do I add & remove values from a hidden input field?
body: <pre><code>&lt;input type="hidden" id="values" value="1,2,1,3" /&gt;
  
  &lt;a href="#" id="add" data-value="4"&gt;add&lt;/a&gt;
  
  &lt;a href="#" id="remove" data-value="1"&gt;remove&lt;/a&gt;
  
  &lt;script type="text/javascript"&gt;
  $(document).ready(function()
  {
      $('#add').click(function()
      {
          var value = $(this).attr('data-value');
  
          //add to $('#values')
  
          return false;
      });
  
      $('#remove').click(function()
      {
          var value = $(this).attr('data-value');
  
          //remove all values that match in $('#values');
  
          return false;
      });
  });
  &lt;/script&gt;
  </code></pre>
  
  <p><strong>Examples</strong></p>
  
  <p>a) Add, output would be: 1,2,1,3,4</p>
  
  <p>b) Remove, output would be 2,3</p>