I've been struggling with this troubleshooting issue and despite researching API documentation and looking for answers on Stackoverflow, I haven't been able to find a solution. The accordion div in my HTML code seems to have the correct CSS styling, but it's not functioning as an accordion. Here is the HTML code snippet:
<div id="accordion" class="ui-accordion">
<ul>
<h3 class="ui-accordion-header">Page One</h3>
<div>
<li class="ui-accordion-content"><a href="#1a">Subpage 1A</a>
</li>
<li class="ui-accordion-content"><a href="#1b">Subpage 1B</a>
</li>
<li class="ui-accordion-content"><a href="#1c">Subpage 1C</a>
</li>
</div>
<h3 class="ui-accordion-header">Page Two</h3>
<div>
<li class="ui-accordion-content"><a href="#2a">Subpage 2A</a>
</li>
<li class="ui-accordion-content"><a href="#2b">Subpage 2B</a>
</li>
<li class="ui-accordion-content"><a href="#2c">Subpage 2C</a>
</li>
</div>
<h3 class="ui-accordion-header">Page Three</h3>
<div>
<li class="ui-accordion-content"><a href="#3a">Subpage 3A</a>
</li>
<li class="ui-accordion-content"><a href="#3b">Subpage 3B</a>
</li>
<li class="ui-accordion-content"><a href="#3c">Subpage 3C</a>
</li>
</div>
</ul>
</div>
My JavaScript code looks like this:
$(document).ready(function () {
$('#accordion').accordion();
});
Additionally, here is the CSS styling for the elements displayed:
.ui-accordion .ui-accordion-header {
display: block;
cursor: pointer;
position: relative;
margin-top: 2px;
padding: .5em .5em .5em .7em;
min-height: 0; /* support: IE7 */
}
.ui-accordion .ui-accordion-icons {
padding-left: 2.2em;
}
.ui-accordion .ui-accordion-noicons {
padding-left: .7em;
}
.ui-accordion .ui-accordion-icons .ui-accordion-icons {
padding-left: 2.2em;
}
.ui-accordion .ui-accordion-header .ui-accordion-header-icon {
position: absolute;
left: .5em;
top: 50%;
margin-top: -8px;
}
.ui-accordion .ui-accordion-content {
padding: 1em 2.2em;
border-top: 0;
overflow: auto;
}
You can view the example on this jsFiddle link:
Please take a look and let me know how I can fix this issue with collapsing and expanding.