javascript - Bootstrap 标签输入事件示例

标签 javascript jquery bootstrap-tags-input

我想使用类似此代码的bootstrap tag input事件,但事件不会触发。

 $('#lastStep')
   .find('#input')
       // Revalidate the cities field when it is changed
       .change(function (e) {
           $('#lastStep').formValidation('revalidateField', 'cities');
       })

       .end()
   .formValidation({
       framework: 'bootstrap',
       excluded: ':disabled',

   })


    $("#input").on('itemRemoved', function (event) {
        alert(33)
    });


如何解决呢?

最佳答案

如果没有表单验证,它会完美运行

<!DOCTYPE html>
<html>
<head lang="en">
  <meta charset="UTF-8">
  <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
  <script src="bootstrap-tagsinput.js"></script>

  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/twitter-bootstrap/3.2.0/css/bootstrap.min.css">
  <link href="bootstrap-tagsinput.css" rel="stylesheet" type="text/css">

</head>
<body>

<script>
  $(document).ready(function () {
    $("#input").on('itemRemoved', function (event) {
      alert(33)
    });
  });
</script>

<div id="lastStep">
  <input type="text" id="input" data-role="tagsinput" value="Amsterdam,Washington,Sydney,Beijing,Cairo">
</div>

</body>
</html>

关于javascript - Bootstrap 标签输入事件示例,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/30219803/

相关文章:

javascript - 为什么 Nest.js 声称是 "progressive"?

javascript - 对文本区域的验证不起作用我该如何调试它

javascript - 如何检查嵌套 Jest 模拟函数中是否调用了方法

jquery - 工具 slider Z-Index 分层问题

jquery - 使用 jquery 动态添加 Canvas 的 getContext(2d)

javascript - DOMException : play() can only be initiated by a user gesture

javascript - 获取元素相对于最顶层窗口的位置的函数

javascript - Bootstrap-TagsInput 确认键不起作用

jquery - 页面加载时如何锁定/只读 Bootstrap 标签输入字段?