twitter-bootstrap 未捕获的类型错误:$(...).multiselect 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37837985/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 23:59:53  来源:igfitidea点击:

Uncaught TypeError: $(…).multiselect is not a function

jqueryhtmltwitter-bootstrapbootstrap-multiselect

提问by Proto

I'm trying to use the multi select plugin (http://davidstutz.github.io/bootstrap-multiselect/)

我正在尝试使用多选插件(http://davidstutz.github.io/bootstrap-multiselect/

I get the folllowing error: $(...).multiselect is not a function

我得到以下错误: $(...).multiselect is not a function

and I can't figure out how to make it work...

我不知道如何让它工作......

<!-- Include Twitter Bootstrap and jQuery: -->
<link rel="stylesheet" href="css/bootstrap.min.css" type="text/css"/>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>

<!-- Include the plugin's CSS and JS: -->
<script type="text/javascript" src="js/bootstrap-multiselect.js"></script>
<link rel="stylesheet" href="css/bootstrap-multiselect.css" type="text/css"/>

Here is my select:

这是我的选择:

<select class="multiselect" multiple="multiple">
    <option value="0">value0</option>
    <option value="1">value1</option>
    <option value="2">value2</option>
    <option value="3">value3</option>
</select>

And then I call the plugin:

然后我调用插件:

<script type="text/javascript">
    $(document).ready(function(){
    $('.multiselect').multiselect();
    });
</script>

I've tried to call the plugin where I link the css and js, but it still won't work.

我试图调用我链接 css 和 js 的插件,但它仍然不起作用。

回答by Proto

I found my mistake!

我发现了我的错误!

I was linking another jquery.min.js further in my code. Now it works just fine!

我在我的代码中进一步链接了另一个 jquery.min.js。现在它工作得很好!

回答by Bernabé Tavarez

If you're working with ASP.Net check the follow. If the Master Page has JS or CSS in your aspx don't put them again, 'cause the aspx Inherits from the Master Page. Just put the missing ones.

如果您正在使用 ASP.Net,请检查以下内容。如果母版页在您的 aspx 中有 JS 或 CSS,请不要再放它们,因为 aspx 是从母版页继承的。把缺少的放上来。