Selecting Custom Menu Header
Menu 1
To programmatically change which elements are the panel headers after initial setup:
$("selector").accordion("option", "header", "CSS / jQuery selector");
Menu 2
This example uses p elements as the headers. The ability to change what element is used for the headers allows for more formatting options.
Code
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" href="http://code.jquery.com/ui/1.10.4/themes/cupertino/jquery-ui.css" type="text/css"/>
<script type="text/javascript" src="http://code.jquery.com/jquery-1.10.2.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.10.4/jquery-ui.min.js"></script>
<script type="text/javascript">
// $(function() { code }); executes the contained code when the DOM is finished loading
$(function()
{
// Call the accordion method on the element with the id example
$("#example").accordion(
{
header: "p" // Use p elements inside #example as the headers
});
});
</script>
</head>
<body>
<div id="example">
<p>Menu 1</p>
<h3>This is some placeholder content in an h3 element.</h3>
<p>Menu 2</p>
<h3>This is more placeholder content in a second h3 element.
It is coded directly below an p element which jQuery's
accordion method turns into the header you see above this content.
</h3>
<p>Code</p>
<pre> *** This is what you are viewing *** </pre>
</div>
</body>
</html>