我有一個div <div id="detailTable" width="100%">
中,我添加各種小工具,有時其他內容,所以爲了使jsp頁面不看繁瑣,我刪除任何現有的元素中detailTable
和一些點擊添加內容。現在我想添加一個jQuery手風琴,但它似乎不起作用。請在此提供解決方案。由於如何動態添加jquery手風琴到頁面?
下面是我在做什麼,除去和detailTable
按鈕添加手風琴點擊
$('#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');
我的截圖,在這裏,我只是得到一個應該是在所有的手風琴,但沒有效果。
@val,你如何處理ID的內部HTML被克隆?像「#hcAccordion」?另外,如果你使用課程,當動畫停止時,手風琴將動畫並在屏幕上顯示。較好地保持html_data作爲函數 – hungryMind
外字符串多數民衆贊成什麼意見解釋說,ID是不好的,他/她應該使用類,HTML(html_data)將攜結構手風琴... – Val
@val:hcAccordion將只有一次,你是否注意到'$('#detailTable')。空();'因爲我使用它來刪除所有內容,所以我不能在我的html中添加'hidden_wrapper' ..我是否正確? – abi1964