简体   繁体   English

bootstrap collapse()函数不起作用

[英]bootstrap collapse() function not working

I'm using bootstrap to collapse parts of my website. 我正在使用bootstrap来折叠我网站的部分内容。 It all works fine. 一切正常。 But when I try to control the behaviour manually by javascript, it does not work 但是当我尝试通过javascript手动控制行为时,它不起作用

for example when I do this: 例如,当我这样做时:

 $(".collapse").collapse('hide');

or exactly this: 或者恰恰是这个:

  $(".collapse").each(function () {
            if (localStorage.getItem(this.id)) {
                $(this).collapse('hide');
            }

it does not work. 这是行不通的。 I get this error: Object doesn't support property or method 'collapse' bootstrap. 我收到此错误:对象不支持属性或方法'collapse'引导程序。

I saw similar examples online. 我在网上看到类似的例子。 What am I doing wrong? 我究竟做错了什么? Thanks for any help. 谢谢你的帮助。

Update: 更新:

The Problem was related to different jquery-versions in my asp.net mvc project. 问题与我的asp.net mvc项目中的不同jquery版本有关。 Removing this line of code from _Layout.cshtml fixed it: 从_Layout.cshtml中删除这行代码修复了它:

   @Scripts.Render("~/bundles/jquery")

The Problem was related to different jquery-versions in my asp.net mvc project. 问题与我的asp.net mvc项目中的不同jquery版本有关。 Removing this line of code from _Layout.cshtml fixed it: 从_Layout.cshtml中删除这行代码修复了它:

 @Scripts.Render("~/bundles/jquery") 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM