Javascript jQuery UI: TypeError: $(...).accordion 不是函数

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/14898071/
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-08-24 18:16:01  来源:igfitidea点击:

jQuery UI: TypeError: $(...).accordion is not a function

javascriptjqueryjquery-uijquery-ui-accordion

提问by chuckfinley

For some reason the jQuery UI Accordiondoes not work. I keep getting this error:

出于某种原因,jQuery UI 手风琴不起作用。我不断收到此错误:

TypeError: $(...).accordion is not a function

TypeError: $(...).accordion 不是函数

What am i doing wrong? Based on other answers on this site on similar topics, i think it has something to do with the included files.

我究竟做错了什么?根据本网站上类似主题的其他答案,我认为这与包含的文件有关。

My header includes are:

我的标题包括:

<!-- Mobile Specific Metas -->
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">  

<!-- CSS -->
<link rel="stylesheet" href="<?php echo base_url(); ?>css/base_con.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>css/skeleton.css">
<link rel="stylesheet" href="<?php echo base_url(); ?>css/layout.css">

<!--[if lt IE 8]>
<script src="http://ie7-js.googlecode.com/svn/version/2.1(beta4)/IE8.js"></script>
<![endif]-->

<!--[if lt IE 9]>
<script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->

<!-- Favicons -->
<link rel="shortcut icon" href="<?php echo base_url(); ?>images/favicon.ico">
<link rel="apple-touch-icon" href="<?php echo base_url(); ?>images/apple-touch-icon.png">
<link rel="apple-touch-icon" sizes="72x72" href="images/apple-touch-icon-72x72.png">
<link rel="apple-touch-icon" sizes="114x114" href="images/apple-touch-icon-114x114.png">
<link rel="stylesheet" href="<?php echo base_url(); ?>css/custom-theme/jquery-ui-1.10.0.custom.css" type="text/css" />

<!-- Scripts -->
<script src="<?php echo base_url(); ?>js/jquery-1.9.0.js"></script>
<script src="<?php echo base_url(); ?>js/jquery-ui-1.10.0.custom.js"></script>
<script src="<?php echo base_url(); ?>js/responsiveslides.min.js" type="text/javascript">

回答by martynas

This problem could arise from a couple of different things:

这个问题可能来自几个不同的事情:

  • You are not including jQuery UI library.
  • You are including jQuery UI library above the inclusion of jQuery library
  • The path to jQuery UI and jQuery libraries might be incorrect
  • You are using a custom jQuery UI library that does not have an accordion
  • 您不包括 jQuery UI 库。
  • 您在包含 jQuery 库的上方包含了 jQuery UI 库
  • jQuery UI 和 jQuery 库的路径可能不正确
  • 您正在使用没有手风琴的自定义 jQuery UI 库

Since the first two do not apply to you, I would recommend triple-checking the path and using a full jQuery UI library instead of the custom one:

由于前两个不适用于您,我建议三重检查路径并使用完整的 jQuery UI 库而不是自定义库:

<script src="http://code.jquery.com/ui/1.10.0/jquery-ui.js"></script>

回答by Vivek Espa?a

Using two jquery.jsfiles may cause a conflict and result in an errorbeing thrown. Avoid importing two or more jquery.jsfiles.

使用两个jquery.js文件可能会导致冲突并导致抛出错误。避免导入两个或更多jquery.js文件。

回答by Chad Crowe

The order of the js files matters!

js 文件的顺序很重要!

/external/jquery/jquery.js should be listed above jquery-ui.js!

回答by AKS

in your last code lines, include the script in below order :-

在最后的代码行中,按以下顺序包含脚本:-

There is no need to include the below as it will be taken care by above scripts.

无需包含以下内容,因为上面的脚本会处理这些内容。