Reputation: 208
HTML
<div id="cluster">
<div> // some content goes </div>
<div> // some content goes </div>
</div>
jQuery
var content = '<div id="accordion"><h3>Heading</h3><p>Some content</p></div>';
$('#cluster div').click(fn(){
$('#cluster').append(content);
});
Now how can i add accordion to that appended element.
Actually I tried this code to add accordion like this but it is not acting as accordion.
$('#accordion').accordion({
active: false,
collapsible: true
});
Can anyone help how to do that
Upvotes: 0
Views: 174
Reputation: 2455
You can try this : jsfiddle.net/bharatsing/keqLf315/
$('#cluster div').click(function(){
var content="<div class='accordion'><h3>Section 1</h3><div>some content goes</div> </div>";
$('#cluster').append($(content));
Init();
});
function Init(){
$('.accordion').accordion({
active: false,
collapsible: true
});
}
Init();
Upvotes: 1