I'm working on an accordion menu with href link and collapsible header.
The problem is, it collapse the parent when I click the the child accordion. Are there any workaround?
<ul class="accordion">
<li>
<a class="acc-header" href="http://www.google.com">menu - level 1</a>
<h3>+</h3>
<ul class="accordion">
<li>
<a class="acc-header" href="http://www.google.com">menu - level 2-1</a>
<h3>+</h3>
<ul class="accordion">menu - level 3</ul>
</li>
<li>menu - level 2-2</li>
</ul>
</li>
</ul>
<script type="text/javascript">
$(document).ready(function(){
$( ".accordion" ).accordion({
header: "h3",
collapsible: true,
heightStyle: "content",
active: false,
icons: false,
animate: 200,
});
});
</script>
Here is the updated version and it's working. The solution is to use the "event.stopPropagation()
"(as @Renan Araújo mentioned) and remove the header setting on accordion.