Problems implementing the jQueryUI Accordion feature

Asked

Viewed 79 times

0

And I did a quick search on this resource and found this page;

https://jqueryui.com/accordion/

So I created a folder with the name of GUJ and inside this folder I put three files;

One Javascript with the name jquery-2.2.2.min. js and the other with the name jquery-ui.js

And I also put the index.html file.

with these settings;

<!DOCTYPE html>
<html>

 <script type="text/javascript" src="jquery-2.2.2.min.js"></script>
  <script type="text/javascript" src="jquery-ui.js"></script>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">

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

</script>


</head>
<body>
<div id="accordion">
  <h3>First header</h3>
  <div>First content panel</div>
  <h3>Second header</h3>
  <div>Second content panel</div>
</div>


</body>
</html>

It was supposed to have that result;

https://jsfiddle.net/a2w4zs3h/

But nothing has happened.

accept suggestions.

1 answer

2


Remember that in jQuery the script should be used within the function of ready

Do as below and everything will go well:

          $(document).ready(function(e){ // essa é a parte que você esqueceu
            $("#accordion").accordion({
              collapsible: true
            });        
          });

If the answer fits, give an UP.

  • 1

    thank you very much, it worked.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.