我正在學習jQuery,並在before
函數中遇到問題。我正在做的是我有一張fish
的表格,使用detach
將其刪除並放入一個數組中,這樣當我點擊一個按鈕時,它將恢復到原來的位置。這是我下面的內容。我試圖完成的最終結果是把文字(泛油炸比目魚)放回桌子。任何幫助是非常讚賞在jQuery中使用before函數
<table>
<tr>
<td> </td>
<td class="fish">Pan-Fried Halibut</td>
<td> </td>
</tr>
</table>
這裏是jQuery的分開函數:
$("input#btn1").click(function() {
$f = $(".fish").detach();
});
試圖把文本帶回:
$("input#btn2").click(function() {
$(".fish").first().before($f); 'This statement doesnt work; what am i doing wrong
});
你的代碼有什麼問題?我們不介意讀者。 –