简体   繁体   English

无法识别jQuery UI手风琴()函数

[英]Doesn't recognize jQuery UI accordion() function

I'm testing with jQuery-UI and wanted to use the accordion. 我正在用jQuery-UI进行测试,并想使用手风琴。 I made this test accordion: 我做了这个测试手风琴:

<div id="accordion">
      <h3>Section 1</h3>
      <div>
          <p>text text text text text text text text text </p>
      </div>
      <h3>Section 2</h3>
      <div>
          <p>text text text text text text text text text </p>
      </div>
      <h3>Section 3</h3>
      <div>
          <p>text text text text text text text text text </p>
      </div>
      <h3>Section 4</h3>
      <div>
          <p>text text text text text text text text text </p>
      </div>
  </div>

The function: 功能:

$(function(){
    $('#accordion').accordion({
        collapsible: true
    });
});

But I get this error every time I run it: 但是每次运行它都会收到此错误:

> Uncaught TypeError: $(...).accordion is not a function
    at HTMLDocument.<anonymous> (index.js:173)
    at j (jquery.min.js:2)
    at k (jquery.min.js:2)

I downloaded all the needed files from the jQuery site and linked everything but I keep getting this error. 我从jQuery网站下载了所有需要的文件并链接了所有内容,但我一直收到此错误。 I don't know what the problem here is. 我不知道这是什么问题。

use jquery cdn: 使用jQuery CDN:

  <script src="https://code.jquery.com/jquery-1.12.4.js"></script>
  <script src="https://code.jquery.com/ui/1.12.1/jquery-ui.js"></script>

and use 和使用

$( function() {
        $( "#accordion" ).accordion({
             collapsible: "true" //commas
        });
    } );

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

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