我的問題基本上是the same as this one(它從來沒有得到正確的回答)。應用jQuery函數動態添加項目
如何在我動態添加的項目上使用jQuery函數?
具體來說,我想在表格上使用jquery tablesorter plugin,我在用戶做了一些事情之後,在頁面上動態加載頁面。
這裏是我的代碼:
results_html += "<table id='results' class='tablesorter><thead>";
[My table contents go here, ommitted for this question]
results_html += "</tbody></table>";
$('#book_results').html(results_html);
$("#results").tablesorter();
有頁面上沒有JS錯誤,但不被應用的tablesorter功能。我能做什麼?
謝謝!這些代碼
我的代碼實際上與示例有些不同(更長)。但是我沒有在Firebug中看到任何錯誤,即使開啓了嚴格的JavaScript警告。嗯... – AP257 2011-01-23 17:19:24
@ AP257:錯字是否存在於真實的代碼中?如果是這樣,Firefox可能不會生成您期望的DOM結構(並且TableSorter需要)。 – 2011-01-23 17:21:27