简体   繁体   中英

Doesn't recognize jQuery UI accordion() function

I'm testing with jQuery-UI and wanted to use the accordion. 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. I don't know what the problem here is.

use 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
        });
    } );

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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