我在過濾表格後設置變量爲<tbody>
的全部內容,我希望能夠返回到<tbody>
的原始完整內容。目前,當我嘗試更改回原始內容時,jQuery正在剝離<script>
和<td>
元素。jQuery .html()刪除html元素
JavScript
var contents= $("tbody").html();
//load of other functions
$("tbody").html(contents);
內容看起來有點像這樣:
<script>alert("Hello");</script>
<tr>
<td>A value</td>
<td>Another value</td>
</tr>
當我試圖恢復到這個內容,我得到:
A value
Another value
那麼究竟是$(「tbody」)。html()放在你的代碼結尾的字符串結果是什麼?這是你最後的輸出顯示,有一些結果沒有HTML標籤呢? – nsanders 2012-01-06 19:22:42