gpt4 book ai didi

javascript - $(...).tagsinput 不是函数

转载 作者:行者123 更新时间:2023-11-29 16:07:35 25 4
gpt4 key购买 nike

我一定是遗漏了一些简单的东西,但我看不到它。我正在使用 Bootstrap tagsinput 插件,我正在尝试遵循此处的一些示例: http://bootstrap-tagsinput.github.io/bootstrap-tagsinput/examples/

这是我的代码:

<html>
<head>
<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css" rel="stylesheet">
<link rel="stylesheet" href="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.css" />
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script>
<script src="https://cdn.jsdelivr.net/bootstrap.tagsinput/0.4.2/bootstrap-tagsinput.min.js"></script>
</head>
<body>
<input id="cities" class="form-control" value="New York,London" data-role="tagsinput" type="text">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
<script>
$(function() {
$('#cities').tagsinput({
maxTags: 3
});
});
</script>
</body>
</html>

我收到以下 Javascript 错误:

tagsinput.html:15 Uncaught TypeError: $(...).tagsinput is not a function

我尝试按照 this SO answer 中的建议删除 data-role="tagsinput"但输入变为常规文本框,异常仍然发生。

我做错了什么?

最佳答案

你在你的 script 标签中加载了 2 个 jquery min 文件。

删除 bootstrap-tagsinput.min.js 之后的那个,或者因为第二个是较新的版本加载而不是第一个。

http://jsbin.com/xarasebibi/edit?html,output

关于javascript - $(...).tagsinput 不是函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37222144/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com