Store added tags values in variable
<p>I have an add tag form which includes input field and button. The user can enter multiple tags. Tags are separated by a comma.<br>
Everything is working fine but I want to store added tags values in a variable using javascript, jquery.<br>
Here is what I have done so far -  </p>

<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>$("#tags input").on({
        focusout: function () {
            var txt = this.value.replace(/[^a-z0-9\+\-\.\#]/ig, ''); // allowed characters
            if (txt) $("&lt;span/&gt;", {text: txt.toLowerCase(), insertBefore: this});
            this.value = "";   // To remove entered value after inserting comma
        },
        keyup: function (ev) {
            // if: comma|enter (delimit more keyCodes with | pipe)
            if (/(188|13)/.test(ev.which)) $(this).focusout();
        }
    });
    $('#tags').on('click', 'span', function () {
        if (confirm("Remove " + $(this).text() + "?")) $(this).remove();
    });

    $(document).on('click', '#select_all', function () {

        if (this.checked) {
            $('.all').each(function () {
                this.checked = true;
            });
        } else {
            $('.all').each(function () {
                this.checked = false;
            });
        }

    });  

$('#add_tag_btn').click(function () {    
  // Here I want to store added tags values in variable.          
        var added_tags=$('#tags span').html();
        alert(added_tags);
 });</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"&gt;&lt;/script&gt;
&lt;form&gt;
  &lt;div id="tags"&gt;
    &lt;input type="text" value="" class="form-control"   id="add_tag"placeholder="Add tag" /&gt;
  &lt;/div&gt;
    &lt;input type='button' class='btn btn-primary' id='add_tag_btn' value='Add'&gt;
&lt;/form&gt;</code></pre>
</div>
</div>
</p>