title: Getting value of multiple <span> tags in HTML/JavaScript?
body: <p>I'm hoping someone can help me out with this...I followed the tutorial here: <a href="http://jsbin.com/hehurot/5/edit?html,css,js,console,output" rel="nofollow">http://jsbin.com/hehurot/5/edit?html,css,js,console,output</a> to create a field on an HTML form which contains tags. Now when I click submit on my form I want to grab the data in that field with tags and do something with it (save to database). </p>
  
  <p>How would I go about grabbing the data from the field since each tag is a ? </p>
  
  <p>Here is my current code for the tag field: </p>
  
  <pre><code>&lt;div class="form-group"&gt;
      &lt;label class="col-sm-3 control-label"&gt;Equipment&lt;/label&gt;
      &lt;div id="tags" class="col-sm-9"&gt;
         &lt;span&gt;Hardhat&lt;/span&gt;
         &lt;span&gt;Steel Toe Boots&lt;/span&gt;
         &lt;input id="equipment" type="text" name="equipment" value="" placeholder="Add equipment" &gt;
      &lt;/div&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>The JS to make the tag field work (the CSS is available on the link above)</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
        $(function(){ 
          $("#tags input").on({
            focusout : function() {
              var txt= this.value.replace(/[^a-z0-9\+\-\.\#]/ig,'');
              if(txt) $("&lt;span/&gt;",{text:txt.toLowerCase(), insertBefore:this});
              this.value="";
            },
            keyup : function(ev) {
              if(/(188|13)/.test(ev.which)) $(this).focusout(); 
            }
          });
          $('#tags').on('click', 'span', function() {
            /*if(confirm("Remove "+ $(this).text() +"?")) */$(this).remove(); 
          });
        });
  &lt;/script&gt;
  </code></pre>
  
  <p>Now in my JS file, how can I get the values saved as separate 's?</p>
  
  <p>I tried the following but this does not work, returns empty string:</p>
  
  <pre><code>'equipment': $('#tags').val()
  </code></pre>
  
  <p>Thanks in advance for the help!</p>