Jquery 在同一个表中排序并放入不同的表
我的代码中有两个表。我想在同一个表中对行进行排序,并在不同的表中拖放 因此,我使用了可排序和可拖动、可拖放的函数。但只有一个在工作 (取决于使用id和类) 我是新来的,所以我不知道如何给出链接,所以我将我的代码粘贴到这里,其中只有拖放功能,没有排序功能 这是我的脚本部分Jquery 在同一个表中排序并放入不同的表,jquery,jquery-ui-draggable,jquery-ui-sortable,jquery-ui-droppable,Jquery,Jquery Ui Draggable,Jquery Ui Sortable,Jquery Ui Droppable,我的代码中有两个表。我想在同一个表中对行进行排序,并在不同的表中拖放 因此,我使用了可排序和可拖动、可拖放的函数。但只有一个在工作 (取决于使用id和类) 我是新来的,所以我不知道如何给出链接,所以我将我的代码粘贴到这里,其中只有拖放功能,没有排序功能 这是我的脚本部分 <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></s
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.8.18/jquery-ui.min.js"></script>
<script type="text/javascript">//<![CDATA[
$(window).load(function () {
var fixHelperModified = function (e, tr) {
var $originals = tr.children();
var $helper = tr.clone();
$helper.children().each(function (index) {
$(this).width($originals.eq(index).width())
});
return $helper;
},
updateIndex = function (e, ui) {
$('td.index', ui.item.parent()).each(function (i) {
$(this).html(i + 1);
});
};
$(".grid tbody").sortable({
helper: fixHelperModified,
stop: updateIndex
}).disableSelection();
});//]]>
</script>
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script type="text/javascript" src="http://code.jquery.com/ui/1.9.2/jquery-ui.js"></script>
<script type="text/javascript">
$(window).load(function () {
$("#dragdrop tr, #dragdrop1 tr").draggable({
helper: 'clone',
revert: 'invalid',
start: function (event, ui) {
$(this).css('opacity', '.5');
},
stop: function (event, ui) {
$(this).css('opacity', '1');
}
});
$("#dragdrop, #dragdrop1").droppable({
drop: function (event, ui) {
$(ui.draggable).appendTo(this);
//alert($(ui.draggable).text());
//fire ajax here if needed
}
});
});
</script>
//
$(窗口)。加载(函数(){
$(“#dragdrop tr,#dragdrop 1 tr”)。可拖动({
助手:“克隆”,
还原:“无效”,
开始:功能(事件、用户界面){
$(this.css('opacity','.5');
},
停止:功能(事件、用户界面){
$(this.css('opacity','1');
}
});
$(“#dragdrop,#dragdrop 1”)。可拖放({
drop:函数(事件、用户界面){
$(ui.draggable).appendTo(this);
//警报($(ui.draggable.text());
//如果需要,在这里发射ajax
}
});
});
这是我的风格
表{边框:棕色1px实心}
头部
<h1>Table one</h1>
<table id="dragdrop" class="grid" title="Kurt Vonnegut novels">
<thead>
<tr>
<th class="index">No.</th>
<th>Year</th>
<th>Title</th>
<th>Grade</th>
</tr>
</thead>
<tbody>
<tr>
<td class="index">1</td>
<td>1969</td>
<td>Slaughterhouse-Five</td>
<td>A+</td>
</tr>
<tr>
<td class="index">2</td>
<td>1952</td>
<td>Player Piano</td>
<td>B</td>
</tr>
<tr>
<td class="index">3</td>
<td>1963</td>
<td>Cat's Cradle</td>
<td>A+</td>
</tr>
<tr>
<td class="index">4</td>
<td>1973</td>
<td>Breakfast of Champions</td>
<td>C</td>
</tr>
<tr>
<td class="index">5</td>
<td>1965</td>
<td>God Bless You, Mr. Rosewater</td>
<td>A</td>
</tr>
</tbody>
</table>
<h1>Table two</h1>
<table id="dragdrop1" class="grid" title="Kurt Vonnegut novels">
<thead>
<tr>
<th class="index">No.</th>
<th>1Year</th>
<th>1Title</th>
<th>1Grade</th>
</tr>
</thead>
<tbody>
<tr>
<td class="index">1</td>
<td>11969</td>
<td>1Slaughterhouse-Five</td>
<td>1A+</td>
</tr>
<tr>
<td class="index">2</td>
<td>11952</td>
<td>1Player Piano</td>
<td>1B</td>
</tr>
<tr>
<td class="index">3</td>
<td>11963</td>
<td>1Cat's Cradle</td>
<td>1A+</td>
</tr>
<tr>
<td class="index">4</td>
<td>11973</td>
<td>1Breakfast of Champions</td>
<td>1C</td>
</tr>
<tr>
<td class="index">5</td>
<td>11965</td>
<td>1God Bless You, Mr. Rosewater</td>
<td>1A</td>
</tr>
</tbody>
</table>
表一
不
年
标题
等级
1.
1969
第五屠宰场
A+
2.
1952
钢琴演奏者
B
3.
1963
猫的摇篮
A+
4.
1973
冠军早餐
C
5.
1965
上帝保佑你,罗斯沃特先生
A.
表二
不
1年
1标题
1级
1.
11969
五号餐厅
1A+
2.
11952
1层钢琴
1B
3.
11963
猫的摇篮
1A+
4.
11973
1冠军早餐
1C
5.
11965
上帝保佑你,罗斯沃特先生
1A
嘿,我没有完全得到这个问题的答案。
所以我在用。它完全符合我的要求