I have a div <div id="detailTable" width="100%"> in which i append different widgets sometimes other content, so in order for the jsp page not to look cumbersome, i am removing any existing elements inside detailTable and adding contents on some click. Now I want to add a jQuery accordion but it does not seem to work. Please provide a solution in this context. Thanks
Here is what i am doing to remove and add accordion in detailTable on button click
$('#detailTable').empty();
$('<div>')
.attr('id','healthCheckSpan')
.html('<div class="titleBlue">Health Check Summary</div>'+
'<table style="border:#2F5882 1px solid;width:100%;" cellspacing="1" cellpadding="1">'+
'<thead>'+
'<tr style="color :#FFFFFF;background-color: #8EA4BB">'+
'<th width="10%" align="center"><b>Recommendations</b></th>'+
'</tr>'+
'</thead>'+
'<tbody >'+
'<tr style="color :#2F5882;background-color: #EDF1F5">'+
'<td align="left" width="10%">'+
'<span id="recommendations">'+
'<div id="hcAccordion">'+
'<h3><a href="#">Error</a></h3>'+
'<div><p id="errorhc">ERROR'+
'</p></div>'+
'<h3><a href="#">Warning</a></h3>'+
'<div><p id="warninghc">WARNING'+
'</p></div>'+
'<h3><a href="#">Info</a></h3>'+
'<div><p id="infohc">INFO'+
'</p></div>'+
'</div>'+
'<script>$(document).ready(function(){'+
'$(function() { $( "#hcAccordion" ).accordion(); });'+
'});</script>'+
'</span>'+
'</td>'+
'</tr>'+
'</tbody>'+
'</table>'+
'</div>')
.appendTo('#detailTable');
My screenshot, here i just get a supposed to be accordion but no effects at all.
firstly you should remove that ugly
html('....blabla....');it’s terrible…put that in your normal html, and hide it, then copy it using
clone(),jquery
html