What am I doing wrong. The accordion works, but when I try to open it from external link (fx. mysite.com/mypage.php#2) - it wont open the accordion!
My header is:
<script type="text/javascript" src="//code.jquery.com/jquery-1.10.2.js"></script>
<script type="text/javascript" src="//code.jquery.com/ui/1.10.4/jquery-ui.js"></script>
<script>
$(document).ready(function() {
$("#accordion").accordion({
active: false,
collapsible: true,
autoHeight: false,
navigation: true,
header: '.menuitem'
});
$(".menuitem").click(function(event){
window.location.hash=this.hash;
});
});
</script>
My html is:
<div id="accordion">
<a class="menuitem" href="#1">Header 1</a>
<!-- accordion panel --><div>
CONTENT 1</>
<!-- end accordion panel --></div>
<a class="menuitem" href="#2">Header 2</a>
<!-- accordion panel --><div>
CONTENT 2</>
<!-- end accordion panel --></div>
<!-- end accordion -->
You can do something like this, though not a perfect solution:
Many changes might be required..
Your accordeon is a dynamic element in your page (driven with some javascript code).
Setting an html anchor in your url (like #2) will not trigger the accordeon code, you are simply instructing the browser to navigate to the anchored element !
You will need to add some javascript code to your page to get the value of the anchor and pass this parameter to your accordeon widget.
Here is the working code - Jsfiddle Link
@Ashis Your code works perfectly only, every DIV has the same size, so, when I have a DIV with 2 lines, there is a lot of white space beneath. When it contains a lot of information, the DIV is nicely filled.