【发布时间】:2018-05-26 13:44:20
【问题描述】:
我有一个搜索框和几个复选框。选中后,复选框中的值将被推送到搜索框中。
现在我想对推入搜索框中的每个字符串使用 Bootstrap 标签输入,使其看起来像一个标签,但我在标题中收到错误消息。
我使用标签输入错误吗?
$(document).ready(function () {
$checks = $(":checkbox");
$checks.on('change', function () {
var ingredient = $checks.filter(":checked").map(function (i, v) {
return this.id;
}).get().join(" ");
$('#SearchString').tagsinput(ingredient);
}).trigger('change');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<link href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.8.0/bootstrap-tagsinput.css" rel="stylesheet" />
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet" />
<script src="https://code.jquery.com/jquery-3.2.1.js"></script>
<script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.8.0/bootstrap-tagsinput.min.js"></script>
<input class="form-control" id="SearchString" data-role="tagsinput" name="SearchString" type="text" value="">
【问题讨论】:
-
可能是第二个jquery.js链接造成的,不会吧?没有理由链接jquery两次,第二次在taginput.js之后
标签: jquery checkbox input twitter-bootstrap-3 tags