Im using this:
<script>
$(function() {
$( "#accordion" ).accordion();
});
</script>
To get the effect of expand/collapse. (If you know a better plugin or method, pls notice me)
I have this div: <div id ="accordion"></div>
And this code to create a button inside that div. (dont worry about the content of button)
$('#button_submit').click(function()
{
$("#accordion").append(
$("<button id=saved"+j+">").click(function() {
drawChart.apply(null, myArray);
}).html("<b>Start date:</b>"+""+myArray[0]+"\n<b>End date:</b>"+myArray[1]+"\n<b>Chart type:</b>"+myArray[2]+"")
);
My question is, how to create/format div accordion to have this effect accordion effect jquery .
being that the <button id=saved"+j+"> should appear inside the sections.
Cheers
Here’s the code you need. The problem, as I mentioned before is you are adding the button to the main div and not to the sections.
jsFiddle (working example)
Alt Example (possibly cleaner)
This one allows adding new accordion pieces (with button inside)
Be sure your HTML Layout is correct.