0

I try to do something after a tag was added into input box, I know there are event in Tags Input Bootstrap called itemAdded. But I don't why, but my code is not working.

HTML:

`<input id = "zipcode" method ="post" type="text" class = "m-wrap tags" />`

JS:

<script type="text/javascript">
  $(document).ready(function() {
    $('.tags').tagsInput({
            'width': 'auto',
            'defaultText': 'e.g. 48108'
  });
});

  $('#zipcode').on('itemAdded', function(event) {
      // do something with event.item at here. example:
      alert(event.item);
  });

</script>

Don't know why this is not working. When I input new tag, nothing happen.

Thank you.

4

1 回答 1

0

为什么不直接使用 change、blur 或 mouseleave 事件?您可能还想仔细检查您的 HTML。它可能格式不正确。IE id 和 class 属性之间的额外空格。

<input id="zipcode" method ="post" type="text" class="m-wrap tags" />
于 2016-10-13T22:41:02.997 回答