[jQuery] Unexpected behaviour in modifying a form field

[jQuery] Unexpected behaviour in modifying a form field


Hi,
the code below is supposed to parse the tags/words specified in an
input field and remove the last one once the link corresponding to
this selector "div#side-content div#tags a:first" is clicked.
Unfortunately all the tags/words are removed when such a link is
clicked and I can't figure out why. Do you have any idea?
Many thanks
Francesco
$(function(){
function parse_tag_input() {
    tag_input = $("div#main-content input#tags").val();
    re = /[' ']+/;
    tags = $.trim(tag_input).split(re);
    if (tags.length == 1 & tags[0] == "") { tags = []; }
    return tags;
};
function pop_tag() {
    tags = parse_tag_input();
    tags.pop();
    tags_string = tags.join(' ');
    $("div#main-content input#tags").val(tags_string);
};
$("div#side-content div#tags a:first").click( function (event) {
    event.preventDefault();
    pop_tag();
    });
});