我正在使用以下腳本將<tr>
從表中的任意位置移動到該表的頂部。這發生在ajax表單提交後。該form's - 而不是button's - 類是「頂級」如何使用jQuery禁用/啓用多個按鈕
$(".top").click(function() {
var thisRow = $(this).parent().parent();
var firstRow = thisRow.parent().find("tr:first").not(thisRow);
thisRow.insertBefore(firstRow);
});
一旦物品到達表的頂部,我想禁用Send Item To Top
按鈕。因爲在每個<tr>
另外兩個按鈕的問題變得複雜:Move Item Up By One
和Move Item Down By One
(包括AJAX,太)
一旦<tr>
移動到頂部,我想與Send Item To Top
按鈕沿禁用Move Item Up By One
。另外,我想在單擊Move Item Down By One
時重新啓用它們。
下面的腳本被用於交換<tr>
的上/下移動位置。
注:我不能指定任何我的按鈕的id或類,因爲他們的形式是動態生成的。我只能將表單分配給一個ID或一個類。
// Move item down/up
$(".up,.down").click(function(){
var row = $(this).parents("tr:first");
if ($(this).is(".up")) {
row.insertBefore(row.prev());
} else {
row.insertAfter(row.next());
}
});
下面是HTML:
<tr id="item_168" class="element168">
<td><form action=".." class="top..." method="post" onsubmit="..."><input onclick="" type="submit" value="↑" /></form></td>
<td class="action"><form action="up..." class="up" method="post" onsubmit="..."><input onclick="" type="submit" value="↑" /></form></td>
<td class="action"><form action="down..." class="down" method="post" onsubmit="..." title="Move one"><input onclick="" type="submit" value="↓" /></form></td>
</tr>
請給你的瀏覽器解釋HTML結構以及 – 2010-10-27 12:40:20